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 }
Comment #1 by k.hara.pg — 2013-06-06T22:26:34Z
Comment #2 by github-bugzilla — 2013-06-09T12:51:23Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/66996ba9fa29cb3e83b66fd262158e7633380891 fix Issue 10288 - Direct lambda call and purity inference bug https://github.com/D-Programming-Language/dmd/commit/e5ac1cb6c6c1b7ce07c60a991e7f0626552a9a95 Merge pull request #2143 from 9rnsr/fix10288 Issue 10288 - Direct lambda call and purity inference bug