Bug 10296 – Nested template function 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-07T22:10:00Z
Last change time
2014-05-07T18:21:51Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
k.hara.pg

Comments

Comment #0 by k.hara.pg — 2013-06-07T22:10:19Z
This is similar to bug 10288. Nested function 'bar' accesses to outer scope variable 'a', so it's inferred as impure. But, 'bar' does not access to variables out of 'foo', so the outer function 'foo' should be still inferred as pure so calling 'bar' does not break its purity. pure void main() { foo(); } void foo()() { int[3] a; void bar()() { a[1] = 2; } bar(); pragma(msg, typeof(bar!())); // nothrow @safe void() }
Comment #1 by k.hara.pg — 2013-06-07T22:15:45Z
Comment #2 by github-bugzilla — 2013-06-09T23:16:54Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/acbaadd13c69b82d3485bb3bbc8ab7a3041f2548 fix Issue 10296 - Nested template function call and purity inference bug https://github.com/D-Programming-Language/dmd/commit/f38a573472bf576fdf9319eacdc75e4b5c345d7c Merge pull request #2149 from 9rnsr/fix10296 Issue 10296 - Nested template function call and purity inference bug
Comment #3 by github-bugzilla — 2014-05-07T18:21:51Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/33f2ab82bd9fb51d88927b8048d88c30ea44111e Remove code for bug 7107 and 10296 because they are unnecessary anymore. Now instantiated symbols can reach correct "parent" via `Dsymbol::toParent2()`, because `TemplateInstance::enclosing` is properly calculated in `TemplateInstance::hasNestedArgs`.