Bug 19242 – Strange inferencing by combination of template and lambda

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-09-12T16:10:06Z
Last change time
2024-12-13T19:00:32Z
Assigned to
No Owner
Creator
SHOO
Moved to GitHub: dmd#19484 →

Comments

Comment #0 by zan77137 — 2018-09-12T16:10:06Z
This code doesn't work: -------------- void foo(Ret)(Ret delegate(int) dg) { } // Even though alias func is not specified, // this is selected unnaturally. // Also, if this function is commented out, // the above function(foo(Ret)) is inferred. void foo(alias func)(void delegate(string) dg) { } void main() { foo(a => a + 1); } -------------- dmd -run main.d -------------- main.d(11): Error: incompatible types for `(a) + (1)`: `string` and `int`
Comment #1 by b2.temp — 2018-09-12T16:25:42Z
I don't know if there's a bug or an enhancement possible in the compiler. Selecting the right overload is trivial: ``` foo((int a) => a + 1); ``` If this solution is satisfying you can set the Status as RESOLVED for the reson INVALID.
Comment #2 by b2.temp — 2018-09-12T16:35:28Z
Problem is also that the specs for this kind of stuff are void. Looks like only the last overload of the overload set is tried.
Comment #3 by robert.schadek — 2024-12-13T19:00:32Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19484 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB