Bug 21436 – `-preview=dip1000` breaks type inference for function taking delegate

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-11-28T02:11:25Z
Last change time
2024-12-13T19:13:04Z
Assigned to
No Owner
Creator
andy-hanson
Moved to GitHub: dmd#18003 →

Comments

Comment #0 by andy-hanson — 2020-11-28T02:11:25Z
This code compiles with no error with `dmd app.d` but breaks with `dmd -preview=dip1000 app.d`: ``` void callIt(T)(T a, scope void delegate(T) cb) { cb(a); } void main() { callIt(0, (int x) {}); } ``` With `-preview=dip1000` it fails with: ``` app.d(6): Error: template app.callIt cannot deduce function from argument types !()(int, void function(int x) pure nothrow @nogc @safe), candidates are: app.d(1): callIt(T)(T a, scope void delegate(T) cb) ``` The code compiles without error (with or without `-preview=dip1000`) if a type argument `!int` is provided.
Comment #1 by robert.schadek — 2024-12-13T19:13:04Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18003 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB