From 1a15a3adf6393f70dba41cc6dd4375656b8f0504 Mon Sep 17 00:00:00 2001 From: Pawel Lampe Date: Sun, 21 Nov 2021 21:17:35 +0100 Subject: [PATCH] Fix GDScript parser crash on 'dollar mixed with assignment' expression fixes #53696 --- modules/gdscript/gdscript_parser.cpp | 3 +++ .../tests/scripts/parser/errors/dollar-assignment-bug-53696.gd | 2 ++ .../scripts/parser/errors/dollar-assignment-bug-53696.out | 2 ++ 3 files changed, 7 insertions(+) create mode 100644 modules/gdscript/tests/scripts/parser/errors/dollar-assignment-bug-53696.gd create mode 100644 modules/gdscript/tests/scripts/parser/errors/dollar-assignment-bug-53696.out diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index bde67833220..69fa793059a 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/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; diff --git a/modules/gdscript/tests/scripts/parser/errors/dollar-assignment-bug-53696.gd b/modules/gdscript/tests/scripts/parser/errors/dollar-assignment-bug-53696.gd new file mode 100644 index 00000000000..e9690ee93dd --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/errors/dollar-assignment-bug-53696.gd @@ -0,0 +1,2 @@ +func test(): + $=$ diff --git a/modules/gdscript/tests/scripts/parser/errors/dollar-assignment-bug-53696.out b/modules/gdscript/tests/scripts/parser/errors/dollar-assignment-bug-53696.out new file mode 100644 index 00000000000..b3dc181a22b --- /dev/null +++ b/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 "$".