Bug 24572 – [REG 2.108.0] Faulty template instantiation with lambda expressions

Status
NEW
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-05-28T12:02:57Z
Last change time
2024-12-13T19:35:27Z
Assigned to
No Owner
Creator
SHOO
Moved to GitHub: dmd#20460 →

Comments

Comment #0 by zan77137 — 2024-05-28T12:02:57Z
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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20460 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB