[mcs] Throw expression cannot be placed after any colon.
[mono.git] / mcs / mcs / cs-parser.jay
index 153a6bc7bdba4d8cc56dca48f8c9396ed3e00df3..8d36abae8dc257b8943945bc0cb39a42aa6f76a4 100644 (file)
@@ -4852,6 +4852,15 @@ conditional_expression
                $$ = new Conditional (new BooleanExpression ((Expression) $1), (Expression) $3, (Expression) $5, GetLocation ($2));
                lbag.AddLocation ($$, GetLocation ($4));
          }
+       | null_coalescing_expression INTERR expression COLON THROW prefixed_unary_expression
+         {
+               if (lang_version < LanguageVersion.V_7)
+                       FeatureIsNotAvailable (lexer.Location, "throw expression");
+
+               var expr = new ThrowExpression ((Expression) $6, GetLocation ($5));
+               $$ = new Conditional (new BooleanExpression ((Expression) $1), (Expression) $3, expr, GetLocation ($2));
+               lbag.AddLocation ($$, GetLocation ($4));
+         }
        | null_coalescing_expression INTERR expression error
          {
                Error_SyntaxError (yyToken);