[Mono-bugs] [Bug 30173][Nor] New - nested scope variable declaration

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
11 Sep 2002 11:18:58 -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 lupus@ximian.com.

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

--- shadow/30173	Wed Sep 11 07:18:58 2002
+++ shadow/30173.tmp.27452	Wed Sep 11 07:18:58 2002
@@ -0,0 +1,34 @@
+Bug#: 30173
+Product: Mono/MCS
+Version: unspecified
+OS: other
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: lupus@ximian.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: nested scope variable declaration
+
+The following program should not compile, but it does with mcs on either
+runtime.
+class T {
+        static void Main() {
+                for (int i = 0; i < 2; ++i) {
+                        int a = i;
+                }
+                int a = 5;
+        }
+}
+csc gives the following error:
+inner-decl.cs(6,7): error CS0136: A local variable named 'a' cannot be
+declared in this scope because it would give a different meaning to 'a',
+which is already used in a 'child' scope to denote something else
+inner-decl.cs(6,7): error CS0103: The name 'a' does not exist in the class
+or namespace 'T'