www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14049] New: [REG2.064] Wrong purity inference for nested lambda

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 puremagic.com
          Reporter: k.hara.pg 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'

--
Jan 26 2015