[Issue 14049] New: [REG2.064] Wrong purity inference for nested lambda

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Jan 26 05:09:23 PST 2015


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

          Issue ID: 14049
           Summary: [REG2.064] Wrong purity inference for nested lambda
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: accepts-invalid, wrong-code
          Severity: regression
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: k.hara.pg at gmail.com

This code is correctly rejected with 2.063, but wrongly accepted with 2.064 -
git-head.

auto impure() { return 1; }

void foo(T)(T val)
{
    auto n = ()@trusted{
        return impure();
    }();
}

void bar() pure
{
    foo(1);    // line 12
}

With 2.063:
test.d(12): Error: pure function 'bar' cannot call impure function 'foo'

--


More information about the Digitalmars-d-bugs mailing list