[Issue 21436] New: `-preview=dip1000` breaks type inference for function taking delegate
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Sat Nov 28 02:11:25 UTC 2020
    
    
  
https://issues.dlang.org/show_bug.cgi?id=21436
          Issue ID: 21436
           Summary: `-preview=dip1000` breaks type inference for function
                    taking delegate
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: andy.pj.hanson at gmail.com
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.
--
    
    
More information about the Digitalmars-d-bugs
mailing list