D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6706 - 'inout' is accepted in foreach, but apparently ignored
Summary: 'inout' is accepted in foreach, but apparently ignored
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2011-09-21 04:10 UTC by Don
Modified: 2012-01-30 23:49 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Don 2011-09-21 04:10:10 UTC
This is fail253.d from the test suite. It prints "holahola".
Changing inout into ref restores the original check in the test suite -- but I don't think this should compile.

import std.stdio;

void main() {
    foreach (i; 0 .. 2)
    {
        foreach(inout char x; "hola") {
	    printf("%c", x);
	    x = '?';
        }
    }
}
Comment 1 yebblies 2012-01-30 23:49:50 UTC
This doesn't compile any more. (dmd 2.058)
It was probably fixed with the other inout bugs.