mirror of
https://github.com/godotengine/godot.git
synced 2025-10-23 18:03:35 +00:00
Merge pull request #72512 from vonagam/fix-ternary-type-source
GDScript: Fix type certainty for result of ternary operator
This commit is contained in:
commit
d201df1ffa
5 changed files with 23 additions and 1 deletions
|
|
@ -4113,7 +4113,6 @@ void GDScriptAnalyzer::reduce_ternary_op(GDScriptParser::TernaryOpNode *p_ternar
|
|||
if (!is_type_compatible(true_type, false_type)) {
|
||||
result = false_type;
|
||||
if (!is_type_compatible(false_type, true_type)) {
|
||||
result.type_source = GDScriptParser::DataType::UNDETECTED;
|
||||
result.kind = GDScriptParser::DataType::VARIANT;
|
||||
#ifdef DEBUG_ENABLED
|
||||
parser->push_warning(p_ternary_op, GDScriptWarning::INCOMPATIBLE_TERNARY);
|
||||
|
|
@ -4121,6 +4120,7 @@ void GDScriptAnalyzer::reduce_ternary_op(GDScriptParser::TernaryOpNode *p_ternar
|
|||
}
|
||||
}
|
||||
}
|
||||
result.type_source = true_type.is_hard_type() && false_type.is_hard_type() ? GDScriptParser::DataType::ANNOTATED_INFERRED : GDScriptParser::DataType::INFERRED;
|
||||
|
||||
p_ternary_op->set_datatype(result);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue