Don't crash when reporting invalid case label value. Fixes #13952
authorMarek Safar <marek.safar@gmail.com>
Wed, 14 Aug 2013 13:32:21 +0000 (15:32 +0200)
committerMarek Safar <marek.safar@gmail.com>
Wed, 14 Aug 2013 13:32:21 +0000 (15:32 +0200)
mcs/errors/cs0150-2.cs [new file with mode: 0644]
mcs/mcs/ecore.cs

diff --git a/mcs/errors/cs0150-2.cs b/mcs/errors/cs0150-2.cs
new file mode 100644 (file)
index 0000000..7e20f3f
--- /dev/null
@@ -0,0 +1,18 @@
+// CS0150: A constant value is expected
+// Line : 14
+
+using System;
+
+public class Blah
+{
+       static readonly string Test;
+       
+       public static void Main ()
+       {
+               string s = null;
+               switch (s) {
+                       case Blah.Test:
+                               break;
+               }
+       }
+}
index 54f5c6dff804a3eb5875428a129209742a6578f7..e1f0b14f2a86be01f93947699cccab40f03f8be0 100644 (file)
@@ -526,8 +526,8 @@ namespace Mono.CSharp {
 
                        Constant c = expr as Constant;
                        if (c == null) {
-                               if (c.type != InternalType.ErrorType)
-                                       rc.Report.Error (150, StartLocation, "A constant value is expected");
+                               if (expr.type != InternalType.ErrorType)
+                                       rc.Report.Error (150, expr.StartLocation, "A constant value is expected");
 
                                return null;
                        }