Browse Source

Fix GDScript parser crash on 'dollar mixed with assignment' expression

fixes #53696
Pawel Lampe 3 years ago
parent
commit
1a15a3adf6

+ 3 - 0
modules/gdscript/gdscript_parser.cpp

@@ -2420,6 +2420,9 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_assignment(ExpressionNode
 		push_error("Assignment is not allowed inside an expression.");
 		return parse_expression(false); // Return the following expression.
 	}
+	if (p_previous_operand == nullptr) {
+		return parse_expression(false); // Return the following expression.
+	}
 
 #ifdef DEBUG_ENABLED
 	VariableNode *source_variable = nullptr;

+ 2 - 0
modules/gdscript/tests/scripts/parser/errors/dollar-assignment-bug-53696.gd

@@ -0,0 +1,2 @@
+func test():
+	$=$

+ 2 - 0
modules/gdscript/tests/scripts/parser/errors/dollar-assignment-bug-53696.out

@@ -0,0 +1,2 @@
+GDTEST_PARSER_ERROR
+Expect node path as string or identifier after "$".