mirror of
https://github.com/godotengine/godot.git
synced 2024-12-03 09:52:18 +08:00
Merge pull request #52706 from vnen/gdscript-ternary-operator-crash
GDScript: Show error when missing expression after ternary else
This commit is contained in:
commit
a4187c9235
@ -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;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,4 @@
|
||||
func test():
|
||||
var x = 1 if false else
|
||||
print("oops")
|
||||
print(x)
|
@ -0,0 +1,2 @@
|
||||
GDTEST_PARSER_ERROR
|
||||
Expected expression after "else".
|
Loading…
Reference in New Issue
Block a user