[Mono-bugs] [Bug 24527] New - mcs v0.11 doesn't give arrormessage upon assignment of a readonly variable

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
10 May 2002 17:14:39 -0000


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 detlev@die-offenbachs.de.

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

--- shadow/24527	Fri May 10 13:14:39 2002
+++ shadow/24527.tmp.28507	Fri May 10 13:14:39 2002
@@ -0,0 +1,58 @@
+Bug#: 24527
+Product: Mono/MCS
+Version: unspecified
+OS: 
+OS Details: SuSE 8.0
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: detlev@die-offenbachs.de               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: mcs v0.11 doesn't give arrormessage upon assignment of a readonly variable
+
+mcs v0.11 doesn't catch the error in line 28 of the following code.
+
+---------------------------------------
+
+using System;
+
+public class RightNow {
+    
+    // constructors
+    static RightNow() {
+        DateTime dt = DateTime.Now;
+        Year = dt.Year;
+        Month = dt.Month;
+        Date = dt.Day;
+        Hour = dt.Hour;
+        Minute = dt.Minute;
+        Second = dt.Second;
+    }
+    
+    public static readonly int Year;
+    public static readonly int Month;
+    public static readonly int Date;
+    public static readonly int Hour;
+    public static readonly int Minute;
+    public static readonly int Second;
+}
+
+public class Tester {
+    static void Main() {
+        Console.WriteLine("This year: {0}",
+            RightNow.Year.ToString());
+        RightNow.Year = 2006;
+        Console.WriteLine("This year: {0}",
+            RightNow.Year.ToString());
+    }
+}
+
+---------------------------------------------
+
+An assignment to a readonly variable should not be allowed.