http://d.puremagic.com/issues/show_bug.cgi?id=2807
Summary: Marking a nested function as 'pure' may cause bad code generations silently accepted Product: D Version: 2.027 Platform: PC OS/Version: Windows Status: NEW Keywords: accepts-invalid Severity: critical Priority: P2 Component: DMD AssignedTo: bugzi...@digitalmars.com ReportedBy: clugd...@yahoo.com.au The following assert fails, effectively generating bad code. My patch in #2804 doesn't fix this, but it does reduce the need for marking nested functions as pure. A nested function which is marked as pure should not be able to access variables from the enclosing scope. It's probably adequate to simply disallow 'pure' on nested functions for now. --- pure int double_sqr(int x) { int y = x; void do_sqr() pure { y *= y; } do_sqr(); return y; } void main(string[] args) { assert(double_sqr(10) == 100); } --