GDScript: Show error when missing expression after ternary else

This commit is contained in:
George Marques 2021-09-15 11:43:36 -03:00
parent a5c299630d
commit 107af38fd1
No known key found for this signature in database
GPG key ID: 046BD46A3201E43D
3 changed files with 10 additions and 0 deletions

View file

@ -2275,6 +2275,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".