mirror of
https://github.com/godotengine/godot.git
synced 2025-11-01 06:01:14 +00:00
Merge pull request #74741 from vnen/variant-not-for-everyone
Allow boolean operators for all Variant types
This commit is contained in:
commit
1a62f1e4fc
6 changed files with 639 additions and 3 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue