www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20077] New: Bogus 'need this' for lambda used inside struct

https://issues.dlang.org/show_bug.cgi?id=20077

          Issue ID: 20077
           Summary: Bogus 'need this' for lambda used inside struct
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: simen.kjaras gmail.com

This fails with 'function `S.test!((a) => a).test` need this to access member
test':

struct S {
    pragma(msg, test!(a => a));
}

int test(alias fn)() {
    return fn(3);
}

Clearly, a => a does not need access to `this` in S, and something's gone wrong
in the inference here.

--
Jul 23 2019