diff --git a/Src/Compilers/CSharp/Test/Semantic/Semantics/ForEachTests.cs b/Src/Compilers/CSharp/Test/Semantic/Semantics/ForEachTests.cs index f23f6d177d23eed5db347f96d231cf9e4818e263..f9277dd8d458a35fd80d5035732e3f707d0a48a8 100644 --- a/Src/Compilers/CSharp/Test/Semantic/Semantics/ForEachTests.cs +++ b/Src/Compilers/CSharp/Test/Semantic/Semantics/ForEachTests.cs @@ -949,6 +949,41 @@ void Foo(int i) Diagnostic(ErrorCode.ERR_ForEachMissingMember, "i").WithArguments("int", "GetEnumerator")); } + [Fact(Skip = "Bug 1077204")] + [WorkItem(1077204)] + public void TestIterationVariableIsReadOnly() + { + const string source = @" +using System; + +struct A +{ + public B B; + + static void Main() + { + A[] array = { default(A) }; + + foreach (A a in array) + { + a.B.SetField(5); + Console.Write(a.B.Field); + } + } +} + +struct B +{ + public int Field; + + public void SetField(int value) + { + this.Field = value; + } +}"; + CompileAndVerify(source, expectedOutput: "0"); + } + [Fact] public void TestErrorModifyIterationVariable() {