[Mono-bugs] [Bug 47991][Nor] New - error CS0136 (local variable declaration error) not reported

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Wed, 7 Jan 2004 20:55:12 -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 miguel@ximian.com.

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

--- shadow/47991	2004-01-07 20:55:12.000000000 -0500
+++ shadow/47991.tmp.15635	2004-01-07 20:55:12.000000000 -0500
@@ -0,0 +1,67 @@
+Bug#: 47991
+Product: Mono/Compilers
+Version: unspecified
+OS: unknown
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: Unknown
+Priority: Normal
+Component: C#
+AssignedTo: martin@ximian.com                            
+ReportedBy: sestoft@dina.kvl.dk               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: error CS0136 (local variable declaration error) not reported
+
+Description of Problem:
+
+mcs 0.26 does not report an error CS0136 for the declaration of x in method
+m2 below.  MS csc 1.2 alpha does.  And it should according to C# Lang Spec
+section 3.7.  
+
+This might looks like a repeat of bug 44302, but it is still in mcs
+0.26.
+
+using System;
+
+class Scope {
+  void m1() {         // LEGAL and accepted by mcs 0.26
+    int x;            // declaration of variable x (#2); shadows x (#5)
+    x = 7;            // x #2 in scope
+  }                   //
+
+  void m2() {         // ILLEGAL but not rejected by mcs 0.26:
+    x = 7;            // 
+    int x;            // should be ILLEGAL; would give a new meaning to x
+    x = 7;            // 
+  }                   //
+
+  public int x;
+
+  public static void Main(String[] args) { 
+  }
+}
+
+Steps to reproduce the problem:
+1. Compile program.  
+
+Actual Results:
+
+No complaints from the compiler.
+
+
+Expected Results:
+
+Reject the declaration of x in m2, because x has already been used (as the
+field x from the enclosing class) in m2.  Method m1 is perfectly legal, and
+is accepted by both compilers.
+
+
+How often does this happen? 
+
+Always with mcs 0.26
+
+Additional Information: