diff options
author | Mariano Suligoy <marianognu.easyrpg@gmail.com> | 2021-08-17 21:17:01 -0300 |
---|---|---|
committer | Mariano Suligoy <marianognu.easyrpg@gmail.com> | 2021-08-18 09:19:09 -0300 |
commit | 62077086076fb99fb7fe014522c44ae83f87dc4d (patch) | |
tree | c1a0c691f9c79cfe57f9ab6f1b411cb1d0e8a46b | |
parent | 70c5feb32c0c4cd8c6f6dd2d00f5187f1a57e331 (diff) |
GdScript: Use reduced constant expression result when doing binary operations. Fixes #50293
-rw-r--r-- | modules/gdscript/gdscript_analyzer.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index fe6d1a9240..c9b20463f6 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -1717,11 +1717,19 @@ void GDScriptAnalyzer::reduce_binary_op(GDScriptParser::BinaryOpNode *p_binary_o GDScriptParser::DataType left_type; if (p_binary_op->left_operand) { - left_type = p_binary_op->left_operand->get_datatype(); + if (p_binary_op->left_operand->is_constant) { + left_type = type_from_variant(p_binary_op->left_operand->reduced_value, p_binary_op->left_operand); + } else { + left_type = p_binary_op->left_operand->get_datatype(); + } } GDScriptParser::DataType right_type; if (p_binary_op->right_operand) { - right_type = p_binary_op->right_operand->get_datatype(); + if (p_binary_op->right_operand->is_constant) { + right_type = type_from_variant(p_binary_op->right_operand->reduced_value, p_binary_op->right_operand); + } else { + right_type = p_binary_op->right_operand->get_datatype(); + } } if (!left_type.is_set() || !right_type.is_set()) { |