[Issue 4090] No foreach type inference with const, ref etc modifiers

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Nov 10 05:10:04 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=4090



--- Comment #16 from Kenji Hara <k.hara.pg at gmail.com> 2012-11-10 05:10:01 PST ---
(In reply to comment #15)
> Now this code:
> 
> void main() {
>     int[] array = [10, 20, 30];
>     foreach (const i, x; array) i++;
>     foreach (immutable i, x; array) i++;
> }
> 
> 
> 
> Gives:
> 
> test.d(3): Warning: variable modified in foreach body requires ref storage
> class
> test.d(3): Error: cannot modify const expression i
> test.d(4): Warning: variable modified in foreach body requires ref storage
> class
> test.d(4): Error: cannot modify immutable expression i
> 
> Why is it giving both the warning and the error?

Posted a fix-up pull.
https://github.com/D-Programming-Language/dmd/pull/1276

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list