[Mono-bugs] [Bug 70901][Wis] New - Class const declarations are order dependent

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 30 Dec 2004 17:53:31 -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 jonpryor@vt.edu.

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

--- shadow/70901	2004-12-30 17:53:31.000000000 -0500
+++ shadow/70901.tmp.6236	2004-12-30 17:53:31.000000000 -0500
@@ -0,0 +1,69 @@
+Bug#: 70901
+Product: Mono: Compilers
+Version: 1.1
+OS: other
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: C#
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: jonpryor@vt.edu               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Class const declarations are order dependent
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+
+C# is supposed to be an order-independent language -- it doesn't matter
+which class/method comes first, as long as it's present.  This isn't the
+case when resolving const declarations -- order *is* important, and if the
+definition isn't first, it isn't found.
+
+Steps to reproduce the problem:
+1. Save the following code to cs0117bug.cs:
+
+	// file: cs0117bug.cs
+	// Test bad behavior with CS0117 compiler error
+	using System;
+	using System.Runtime.InteropServices;
+	 
+	class Test {
+		[DllImport (Libs.MyLib)]
+		private static extern void foo ();
+	 
+		public static void Main ()
+		{
+		}
+	}
+	 
+	class Libs {
+		internal const string MyLib = "SomeLibrary";
+	}
+
+
+2. Compile the above file: mcs cs0117bug.cs
+
+Actual Results:
+
+cs0117bug.cs(6) error CS0117: `Libs' does not contain a definition for `MyLib'
+Compilation failed: 1 error(s), 0 warnings
+
+
+Expected Results:
+
+Successful compilation.
+
+How often does this happen? 
+
+All the time.
+
+Additional Information:
+
+If you change the class ordering so that Libs is defined before Test, the
+code compiles successfully.  Consequently, it appears to be an ordering issue.