www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24572] New: [REG 2.108.0] Faulty template instantiation with

https://issues.dlang.org/show_bug.cgi?id=24572

          Issue ID: 24572
           Summary: [REG 2.108.0] Faulty template instantiation with
                    lambda expressions
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: zan77137 nifty.com

There appears to be a regression in the D language compiler between versions
2.107.1 and 2.108.0.
This code has broken since dmd 2.108.0:
----------------
import std;

template isCallableWith(alias F, Args...)
{
    enum bool isCallableWith = __traits(compiles, isCallable!(F!Args));
}
class A
{
    void foo(int dat) { }

    void bar()
    {
        alias lambda1 = (dat) => foo(dat);
        pragma(msg, isCallable!(lambda1!int)); // true
        pragma(msg, isCallableWith!(lambda1, int)); // true

        alias lambda2 = (dat) => foo(dat);
        //pragma(msg, isCallable!(lambda2!int));
        // 2.107.1 -> true / 2.108.0 -> false
        pragma(msg, isCallableWith!(lambda2, int));
    }
}

void main()
{
}
----------------

Actual Behavior:
In version 2.107.1, isCallableWith!(lambda2, int) returns true.
In version 2.108.0, isCallableWith!(lambda2, int) returns false.

Expected Behavior:
isCallableWith!(lambda2, int) should return true, consistent with the behavior
observed in version 2.107.1.

--
May 28