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()
}