[Mono-bugs] [Bug 75322][Wis] New - Failed to compile: A static readonly field can only be assigned in a static constructor

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sun Jun 19 22:34:41 EDT 2005


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 claytonharbour at sporadicism.com.

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

--- shadow/75322	2005-06-19 22:34:41.000000000 -0400
+++ shadow/75322.tmp.10258	2005-06-19 22:34:41.000000000 -0400
@@ -0,0 +1,66 @@
+Bug#: 75322
+Product: Mono: Compilers
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: C#
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: claytonharbour at sporadicism.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Failed to compile: A static readonly field can only be assigned in a static constructor
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+
+
+Steps to reproduce the problem:
+1. Create a HelloWorld.cs with the following code:
+
+using System;
+
+namespace HelloWorld {
+    public class MainClass {
+        private static readonly bool _trueThat = _trueThat = CheckTrueThat();
+
+        public static void Main(string[] args) {
+            Console.WriteLine("HelloWorld");
+        }
+
+        static bool CheckTrueThat() {
+            return true;
+        }
+    }
+}
+
+2. Compile using:
+
+"c:\Program Files\Mono-1.1.8\bin\mcs" /fullpaths /debug "/define:DEBUG"
+"/define:TRACE" /nologo "/target:exe"
+"/out:E:\test\mono\bug-2\Output\HelloWorld.exe" /warnaserror
+"E:\test\mono\bug-2\HelloWorld.cs"
+
+Actual Results:
+
+E:\test\mono\bug-2\HelloWorld.cs(5) error CS0198: A static readonly field
+can only be assigned in a static constructor
+
+Expected Results:
+
+Compiles using csc:
+
+csc /fullpaths /debug "/define:DEBUG" "/define:TRACE" /nologo "/target:exe"
+"/out:E:\test\mono\bug-2\Output\HelloWorld.exe" /warnaserror
+"E:\test\mono\bug-2\HelloWorld.cs"
+
+How often does this happen? Always
+
+Additional Information: Seems to be a regression between 1.1.4 and 1.1.8
+(maybe 1.1.7).


More information about the mono-bugs mailing list