diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-06-18 16:28:10 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-06-18 16:28:10 +0200 |
commit | 1a62f1e4fc853963664ab7afed0085159dcc8082 (patch) | |
tree | b13ab78491f297c173b6795f200b0090d3cb0e4c /modules/gdscript/gdscript_analyzer.cpp | |
parent | 4db1d09bf5a9302b5ea4651c8be6a1f1e7bf4ba8 (diff) | |
parent | d76b3f2a4c7f2e59a0e0592cac8877f382070f14 (diff) | |
download | redot-engine-1a62f1e4fc853963664ab7afed0085159dcc8082.tar.gz |
Merge pull request #74741 from vnen/variant-not-for-everyone
Allow boolean operators for all Variant types
Diffstat (limited to 'modules/gdscript/gdscript_analyzer.cpp')
-rw-r--r-- | modules/gdscript/gdscript_analyzer.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index 6e1ecefba3..5052cc074e 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -4955,6 +4955,17 @@ GDScriptParser::DataType GDScriptAnalyzer::get_operation_type(Variant::Operator } GDScriptParser::DataType GDScriptAnalyzer::get_operation_type(Variant::Operator p_operation, const GDScriptParser::DataType &p_a, const GDScriptParser::DataType &p_b, bool &r_valid, const GDScriptParser::Node *p_source) { + if (p_operation == Variant::OP_AND || p_operation == Variant::OP_OR) { + // Those work for any type of argument and always return a boolean. + // They don't use the Variant operator since they have short-circuit semantics. + r_valid = true; + GDScriptParser::DataType result; + result.type_source = GDScriptParser::DataType::ANNOTATED_INFERRED; + result.kind = GDScriptParser::DataType::BUILTIN; + result.builtin_type = Variant::BOOL; + return result; + } + Variant::Type a_type = p_a.builtin_type; Variant::Type b_type = p_b.builtin_type; |