Browse Source

Fixed GDScript crashed when two consecutive unary operators are analysed

stmSi 2 years ago
parent
commit
2a341a6321
1 changed files with 2 additions and 1 deletions
  1. 2 1
      modules/gdscript/gdscript_analyzer.cpp

+ 2 - 1
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) {
 void GDScriptAnalyzer::reduce_unary_op(GDScriptParser::UnaryOpNode *p_unary_op) {
 	reduce_expression(p_unary_op->operand);
 	reduce_expression(p_unary_op->operand);
 
 
-	GDScriptParser::DataType operand_type = p_unary_op->operand->get_datatype();
 	GDScriptParser::DataType result;
 	GDScriptParser::DataType result;
 
 
 	if (p_unary_op->operand == nullptr) {
 	if (p_unary_op->operand == nullptr) {
@@ -3884,6 +3883,8 @@ void GDScriptAnalyzer::reduce_unary_op(GDScriptParser::UnaryOpNode *p_unary_op)
 		return;
 		return;
 	}
 	}
 
 
+	GDScriptParser::DataType operand_type = p_unary_op->operand->get_datatype();
+
 	if (p_unary_op->operand->is_constant) {
 	if (p_unary_op->operand->is_constant) {
 		p_unary_op->is_constant = true;
 		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());
 		p_unary_op->reduced_value = Variant::evaluate(p_unary_op->variant_op, p_unary_op->operand->reduced_value, Variant());