summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/gdscript_analyzer.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-12-15 23:55:49 +0100
committerRémi Verschelde <rverschelde@gmail.com>2022-12-15 23:55:49 +0100
commitc4b4e69cd9766e14730fe53fdb4330ebec34e3e0 (patch)
treeb2cdf67ac7a86ebfe1e083d3dfe786404ce81fda /modules/gdscript/gdscript_analyzer.cpp
parentd4bbfc7075f5d5716714ba3e77ae52c5d3cdc7bc (diff)
parent2a341a632187343e630f5671e1b9d71776913aeb (diff)
downloadredot-engine-c4b4e69cd9766e14730fe53fdb4330ebec34e3e0.tar.gz
Merge pull request #70126 from stmSi/fixed-gdscript-unary-unary-crash
Fixed GDScript crashed when two consecutive unary operators are analyzed/(script is saved).
Diffstat (limited to 'modules/gdscript/gdscript_analyzer.cpp')
-rw-r--r--modules/gdscript/gdscript_analyzer.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp
index 9ec53b2b66..4da346b1df 100644
--- a/modules/gdscript/gdscript_analyzer.cpp
+++ b/modules/gdscript/gdscript_analyzer.cpp
@@ -3875,7 +3875,6 @@ void GDScriptAnalyzer::reduce_ternary_op(GDScriptParser::TernaryOpNode *p_ternar
void GDScriptAnalyzer::reduce_unary_op(GDScriptParser::UnaryOpNode *p_unary_op) {
reduce_expression(p_unary_op->operand);
- GDScriptParser::DataType operand_type = p_unary_op->operand->get_datatype();
GDScriptParser::DataType result;
if (p_unary_op->operand == nullptr) {
@@ -3884,6 +3883,8 @@ void GDScriptAnalyzer::reduce_unary_op(GDScriptParser::UnaryOpNode *p_unary_op)
return;
}
+ GDScriptParser::DataType operand_type = p_unary_op->operand->get_datatype();
+
if (p_unary_op->operand->is_constant) {
p_unary_op->is_constant = true;
p_unary_op->reduced_value = Variant::evaluate(p_unary_op->variant_op, p_unary_op->operand->reduced_value, Variant());