[Mono-bugs] [Bug 70106][Nor] New - CS1648: setting value to non-readonly member of readonly field fails

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Wed, 1 Dec 2004 14:56:29 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by atsushi@ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=70106

--- shadow/70106	2004-12-01 14:56:29.000000000 -0500
+++ shadow/70106.tmp.16568	2004-12-01 14:56:29.000000000 -0500
@@ -0,0 +1,56 @@
+Bug#: 70106
+Product: Mono: Compilers
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: C#
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: atsushi@ximian.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: CS1648: setting value to non-readonly member of readonly field fails
+
+Current mcs restricts access to non-readonly field of readonly field (in
+the code below, Foo is readonly in Test, but Value is not readonly in Foo).
+In csc, there is no such restriction propagation.
+
+using System;
+
+public class Test
+{
+        public readonly FooType Foo;
+
+        public void Run ()
+        {
+                Foo.Value = "a";
+                Foo.Value = "b";
+        }
+}
+
+public class FooType
+{
+        public string Value;
+}
+
+
+Actual Results:
+cs1648.cs(9) error CS1648: Members of readonly field 'Test.Foo' cannot be
+assign
+ed to (except in a constructor or a variable initializer)
+cs1648.cs(10) error CS1648: Members of readonly field 'Test.Foo' cannot be
+assig
+ned to (except in a constructor or a variable initializer)
+Compilation failed: 2 error(s), 0 warnings
+
+Expected Results:
+no CS1648 error (CS5001: entrypoint not found)
+
+
+How often does this happen? 
+consistently.