diff options
author | Danil Alexeev <danil@alexeev.xyz> | 2023-10-13 12:52:14 +0300 |
---|---|---|
committer | Danil Alexeev <danil@alexeev.xyz> | 2023-10-13 12:52:14 +0300 |
commit | 3ac61aadd7929db650aba7ddc11de61fd75ca2e8 (patch) | |
tree | bb1b55c77f690ae71241360241fb7db87e61eefd /modules/gdscript/gdscript_analyzer.cpp | |
parent | ee118e7ffd97f478de73f4b344fddc0203ef7cca (diff) | |
download | redot-engine-3ac61aadd7929db650aba7ddc11de61fd75ca2e8.tar.gz |
GDScript: Fix unresolved datatype for incomplete expressions
Diffstat (limited to 'modules/gdscript/gdscript_analyzer.cpp')
-rw-r--r-- | modules/gdscript/gdscript_analyzer.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index 831971c3f3..75a1f60310 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -2500,6 +2500,14 @@ void GDScriptAnalyzer::reduce_expression(GDScriptParser::ExpressionNode *p_expre case GDScriptParser::Node::WHILE: ERR_FAIL_MSG("Reaching unreachable case"); } + + if (p_expression->get_datatype().kind == GDScriptParser::DataType::UNRESOLVED) { + // Prevent `is_type_compatible()` errors for incomplete expressions. + // The error can still occur if `reduce_*()` is called directly. + GDScriptParser::DataType dummy; + dummy.kind = GDScriptParser::DataType::VARIANT; + p_expression->set_datatype(dummy); + } } void GDScriptAnalyzer::reduce_array(GDScriptParser::ArrayNode *p_array) { @@ -2802,9 +2810,6 @@ void GDScriptAnalyzer::reduce_binary_op(GDScriptParser::BinaryOpNode *p_binary_o } if (!left_type.is_set() || !right_type.is_set()) { - GDScriptParser::DataType dummy; - dummy.kind = GDScriptParser::DataType::VARIANT; - p_binary_op->set_datatype(dummy); return; } |