[Mono-bugs] [Bug 29213][Wis] New - mcs throws CS0001 when compiling long if-else-if chains

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
20 Aug 2002 22:30:55 -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 nick@chemlab.org.

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

--- shadow/29213	Tue Aug 20 18:30:55 2002
+++ shadow/29213.tmp.9028	Tue Aug 20 18:30:55 2002
@@ -0,0 +1,160 @@
+Bug#: 29213
+Product: Mono/MCS
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: Misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: nick@chemlab.org               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Summary: mcs throws CS0001 when compiling long if-else-if chains
+
+Description of Problem:
+
+Chaining more than 48 if-elses causes mcs to report a syntax error and
+CS0001: THIS IS CRAZY.
+
+Steps to reproduce the problem:
+
+1. Attempts to compile the following source code produce the error.
+
+using System;
+
+public class foobar {
+	public static void Main() {
+		string value = "49";
+
+		if (value == "1")
+			Console.WriteLine(value);
+		else if (value == "2")
+			Console.WriteLine(value);
+		else if (value == "3")
+			Console.WriteLine(value);
+		else if (value == "4")
+			Console.WriteLine(value);
+		else if (value == "5")
+			Console.WriteLine(value);
+		else if (value == "6")
+			Console.WriteLine(value);
+		else if (value == "7")
+			Console.WriteLine(value);
+		else if (value == "8")
+			Console.WriteLine(value);
+		else if (value == "9")
+			Console.WriteLine(value);
+		else if (value == "10")
+			Console.WriteLine(value);
+		else if (value == "11")
+			Console.WriteLine(value);
+		else if (value == "12")
+			Console.WriteLine(value);
+		else if (value == "13")
+			Console.WriteLine(value);
+		else if (value == "14")
+			Console.WriteLine(value);
+		else if (value == "15")
+			Console.WriteLine(value);
+		else if (value == "16")
+			Console.WriteLine(value);
+		else if (value == "17")
+			Console.WriteLine(value);
+		else if (value == "18")
+			Console.WriteLine(value);
+		else if (value == "19")
+			Console.WriteLine(value);
+		else if (value == "20")
+			Console.WriteLine(value);
+		else if (value == "21")
+			Console.WriteLine(value);
+		else if (value == "22")
+			Console.WriteLine(value);
+		else if (value == "23")
+			Console.WriteLine(value);
+		else if (value == "24")
+			Console.WriteLine(value);
+		else if (value == "25")
+			Console.WriteLine(value);
+		else if (value == "26")
+			Console.WriteLine(value);
+		else if (value == "27")
+			Console.WriteLine(value);
+		else if (value == "28")
+			Console.WriteLine(value);
+		else if (value == "29")
+			Console.WriteLine(value);
+		else if (value == "30")
+			Console.WriteLine(value);
+		else if (value == "31")
+			Console.WriteLine(value);
+		else if (value == "32")
+			Console.WriteLine(value);
+		else if (value == "33")
+			Console.WriteLine(value);
+		else if (value == "34")
+			Console.WriteLine(value);
+		else if (value == "35")
+			Console.WriteLine(value);
+		else if (value == "36")
+			Console.WriteLine(value);
+		else if (value == "37")
+			Console.WriteLine(value);
+		else if (value == "38")
+			Console.WriteLine(value);
+		else if (value == "39")
+			Console.WriteLine(value);
+		else if (value == "49")
+			Console.WriteLine(value);
+		else if (value == "41")
+			Console.WriteLine(value);
+		else if (value == "42")
+			Console.WriteLine(value);
+		else if (value == "43")
+			Console.WriteLine(value);
+		else if (value == "44")
+			Console.WriteLine(value);
+		else if (value == "45")
+			Console.WriteLine(value);
+		else if (value == "46")
+			Console.WriteLine(value);
+		else if (value == "47")
+			Console.WriteLine(value);
+		else if (value == "48")
+			Console.WriteLine(value);
+		else
+			Console.WriteLine(value);
+	}
+}
+
+2. Comment out the last else statement or any of the if else statements.
+3. Recompile. It should succeed.
+
+Actual Results:
+
+ganymede:~/tmp$ mcs iftest.cs
+iftest.cs(104) error CS0001: THIS IS CRAZY
+syntax error, expecting CLOSE_PARENS COMMA
+iftest.cs (104,38), Token:353   : Parsing error
+Mono.CSharp.yyParser.yyException: irrecoverable syntax error
+in <0x00856> 00 Mono.CSharp.CSharpParser:yyparse (Mono.CSharp.yyParser.yyInput)
+in <0x0006b> 00 Mono.CSharp.CSharpParser:parse ()
+
+Compilation failed: 1 error(s), 0 warnings
+
+Expected Results:
+
+ganymede:~/tmp$ mcs iftest.cs
+Compilation succeeded
+
+How often does this happen? 
+
+Always.
+
+Additional Information:
+
+Tested with current CVS.