[Mono-bugs] [Bug 22116] New - mcs doesn't consider correctly return paths in switch statement

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
19 Mar 2002 09:31:24 -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=22116

--- shadow/22116	Tue Mar 19 04:31:24 2002
+++ shadow/22116.tmp.19822	Tue Mar 19 04:31:24 2002
@@ -0,0 +1,42 @@
+Bug#: 22116
+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: mcs doesn't consider correctly return paths in switch statement
+
+This included example shows an error when compiled with mcs (both on
+windows and linux):
+.\switch-return.cs(3) error CS161: Not all code paths return a value
+Error: Compilation failed
+
+It doesn't notice that once control is given to the switch, there is always
+a return path from the method.
+
+namespace Simple {
+        public class Test {
+                public static int Main() {
+                        int val = 10;
+
+                        switch (val) {
+                        case 1:
+                                return 1;
+                        case 10:
+                                return 0;
+                        default:
+                                return 1;
+                        }
+                }
+        }
+}