Merge pull request #52706 from vnen/gdscript-ternary-operator-crash

GDScript: Show error when missing expression after ternary else
This commit is contained in:
Rémi Verschelde 2021-09-15 17:20:52 +02:00 committed by GitHub
commit a4187c9235
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 0 deletions

View File

@ -2287,6 +2287,10 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_ternary_operator(Expressio
operation->false_expr = parse_precedence(PREC_TERNARY, false);
if (operation->false_expr == nullptr) {
push_error(R"(Expected expression after "else".)");
}
return operation;
}

View File

@ -0,0 +1,4 @@
func test():
var x = 1 if false else
print("oops")
print(x)

View File

@ -0,0 +1,2 @@
GDTEST_PARSER_ERROR
Expected expression after "else".