This should compile: struct range { int *ptr; @property inout(int)* front() inout { return ptr; } @property bool empty() const { return ptr is null; } void popFront() { ptr = null; } } void main() { int x = 5; auto r = range(&x); foreach(p; r) // line 24 { } } bug.d(24): Error: variable bug.main.p inout variables can only be declared inside inout functions bug.d(24): Error: cannot implicitly convert expression (__r1.front()) of type int* to inout(int)* The range foreach rewrite somehow gets inout into the resulting type of r.front, where it should really be the resulting wild type (in this case int*) Changing the foreach loop to: foreach(int *p; r) { } compiles.
https://github.com/D-Programming-Language/dmd/pull/439
https://github.com/D-Programming-Language/dmd/commit/28b39dece1fe6a4d5c82c7accd04ba380855dd11