Bug 7457 – nested pure functions cannot access mutable context

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-02-07T10:53:00Z
Last change time
2015-03-03T03:54:06Z
Keywords
rejects-valid
Assigned to
nobody
Creator
timon.gehr

Comments

Comment #0 by timon.gehr — 2012-02-07T10:53:41Z
I think the following behavior of DMD is not mirrored in the documentation. void main(){ int x; void foo()pure{x=2;} // error } I think the spec is right, making this an error is problematic: int bar(int delegate()pure dg)pure{return dg();} int foo(int x)pure{ return bar({return x+1;});// error } struct Delegate{ int function(int*)pure fun; int* context; int call()pure{return fun(context);} } int bar2(Delegate dg)pure{return dg.call();} int foo2(int x)pure{ return bar2(Delegate(function(int* ptr){return *ptr+1;}, &x)); // fine }
Comment #1 by k.hara.pg — 2015-03-03T03:54:06Z
This is a dup of issue 9148, so it will be properly fixed in 2.067. *** This issue has been marked as a duplicate of issue 9148 ***