The following program should compile:
pure bool foo(R=int)(string x) {
bool result = false;
foreach (dchar d; x)
result = true;
return result;
}
void main () {
foo("hi");
}
But as of v2.052 it raises the errors:
x.d(4): Error: pure nested function '__foreachbody3' cannot access mutable data 'result'
x.d(9): Error: template instance x.foo!(int) error instantiating
If the template parameter (R=int) were removed, the program compiles successfully. (I think this is related to Issue 3316).
Comment #1 by github-bugzilla — 2014-06-08T02:42:25Z