[Mono-bugs] [Bug 52625][Wis] New - CS0165 compile error - unassigned local variable with while loop
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Tue, 6 Jan 2004 04:33:02 -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 sav912@hotmail.com.
http://bugzilla.ximian.com/show_bug.cgi?id=52625
--- shadow/52625 2004-01-06 04:33:02.000000000 -0500
+++ shadow/52625.tmp.19327 2004-01-06 04:33:02.000000000 -0500
@@ -0,0 +1,70 @@
+Bug#: 52625
+Product: Mono/Compilers
+Version: unspecified
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Wishlist
+Component: C#
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: sav912@hotmail.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: CS0165 compile error - unassigned local variable with while loop
+
+Description of Problem:
+
+The following code compiles without warning using csc. The code below
+
+-----Start code-----
+using System;
+
+class Test
+{
+ public static void Main(String[] args)
+ {
+ string myVar;
+ int counter = 0;
+
+ while (true)
+ {
+ if (counter < 3)
+ {
+ counter++;
+ }
+ else
+ {
+ myVar = "assigned";
+ break;
+ }
+ }
+ //mono compile fails with CS0165 here - unassigned local
+variable
+ Console.WriteLine("myVar = " + myVar);
+ }
+}
+----end code----
+
+
+Steps to reproduce the problem:
+1. Copy code to test.cs
+2. mcs test.cs
+
+Actual Results:
+test.cs(23) error CS0165: Use of unassigned local variable `myVar'
+Compilation failed: 1 error(s), 0 warnings
+
+Expected Results:
+no errors
+
+How often does this happen?
+
+Always
+
+Additional Information:
+
+Is probably related to bug 48393 (same problem with gotos)