Bug 10288 – Direct lambda call and purity inference bug
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-06-06T22:16:00Z
Last change time
2013-06-10T00:30:08Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
k.hara.pg
Comments
Comment #0 by k.hara.pg — 2013-06-06T22:16:56Z
In this code, foo and bar are essentially equivalent, but foo is not inferred to pure.
T foo(T)(T x)
{
() @trusted { x += 10; } ();
return x;
}
T bar(T)(T x)
{
void lambda() @trusted nothrow { x += 10; }
lambda();
return x;
}
@safe pure nothrow void main()
{
assert(foo(10) == 20);
// -> Error: pure function 'main' cannot call impure function 'foo'
assert(bar(10) == 20);
// -> OK
}