[Issue 17659] New: `pure` causes function to be inferred as a delegate

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Jul 17 09:47:53 PDT 2017


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 at puremagic.com
          Reporter: tomer at 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

--


More information about the Digitalmars-d-bugs mailing list