www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21436] New: `-preview=dip1000` breaks type inference for


          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 puremagic.com
          Reporter: andy.pj.hanson 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) {

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.

Nov 27 2020