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.
Comment #1 by robert.schadek — 2024-12-13T19:35:27Z