Try to recover incomplete ternary expression. Fixes #5195
authorMarek Safar <marek.safar@gmail.com>
Sat, 23 Mar 2013 08:59:36 +0000 (09:59 +0100)
committerMarek Safar <marek.safar@gmail.com>
Sun, 24 Mar 2013 10:34:50 +0000 (11:34 +0100)
mcs/errors/cs1525-54.cs [new file with mode: 0644]
mcs/mcs/cs-parser.jay

diff --git a/mcs/errors/cs1525-54.cs b/mcs/errors/cs1525-54.cs
new file mode 100644 (file)
index 0000000..faf331e
--- /dev/null
@@ -0,0 +1,10 @@
+// CS1525: Unexpected symbol `}'
+// Line: 8
+
+class MainClass
+{
+       public string Test ()
+       {
+               return true ? "Hello" :
+       }
+}
index 9330a3eb02da5bbc0cbab366565604f40be949c1..fbd3c2086f8065e28d5b86607da3b482e4b803fe 100644 (file)
@@ -4337,6 +4337,14 @@ conditional_expression
                $$ = new Conditional (new BooleanExpression ((Expression) $1), (Expression) $3, null, GetLocation ($2));
                lbag.AddLocation ($$, GetLocation ($4));
          }
+       | null_coalescing_expression INTERR expression COLON CLOSE_BRACE
+         {
+               Error_SyntaxError (Token.CLOSE_BRACE);
+
+               $$ = new Conditional (new BooleanExpression ((Expression) $1), (Expression) $3, null, GetLocation ($2));
+               lbag.AddLocation ($$, GetLocation ($4));
+               lexer.putback ('}');
+         }
        ;
 
 assignment_expression
@@ -5633,7 +5641,7 @@ for_initializer
                $$ = current_variable;
                if ($4 != null)
                        lbag.AddLocation (current_variable, PopLocation ());
-                       
+
                current_variable = null;
          }
        | statement_expression_list