www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17659] New: `pure` causes function to be inferred as a delegate

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

          Issue ID: 17659
           Summary: `pure` causes function to be inferred as a delegate
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: tomer weka.io

Consider the following

void indirectCall(T)(T fn) {
    pragma(msg, T);
}

__gshared int x;

void f() {
    indirectCall({x++;});      // void function() nothrow  nogc  system
}

void g() pure {
    indirectCall({x++;});     // pure delegate 'dtest.g.__lambda1' cannot
access mutable static data 'x'
}

please ignore the mutable state issue -- the issue here that `{x++}` is treated
as a function

--
Jul 17