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

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
16 Sep 2002 12:43:01 -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 osewa77@yahoo.com.

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

--- shadow/30173	Wed Sep 11 23:04:37 2002
+++ shadow/30173.tmp.31154	Mon Sep 16 08:43:01 2002
@@ -1,12 +1,12 @@
 Bug#: 30173
 Product: Mono/MCS
 Version: unspecified
 OS: other
 OS Details: 
-Status: NEW   
+Status: NEEDINFO   
 Resolution: 
 Severity: Unknown
 Priority: Normal
 Component: Misc
 AssignedTo: martin@gnome.org                            
 ReportedBy: lupus@ximian.com               
@@ -29,6 +29,28 @@
 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'
+
+------- Additional Comments From osewa77@yahoo.com  2002-09-16 08:43 -------
+The following also (wrongly) works:
+
+class T {
+        static void Main() {
+                for (int i = 0; i < 2; ++i) {
+			while(true) {
+				int a = i;
+			}
+                }
+                char a = 'A';
+        }
+}
+
+Difference: this time a is declared as a different type.  So I guess
+the compiler thinks the a inside and the one outside are completely
+different.  Isn't this supposed to be correct?  Interestingly it
+doesn't work this way for other loop construct (like while)
+
+---
+"mind not my infantile posts, for yet learning I am!