summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/gdscript_analyzer.cpp
diff options
context:
space:
mode:
authorcdemirer <41021322+cdemirer@users.noreply.github.com>2022-07-04 01:10:16 +0300
committercdemirer <41021322+cdemirer@users.noreply.github.com>2022-12-25 17:11:30 +0300
commitbbb21c3fd57af58f458b73fce16f2754e6408a53 (patch)
tree3662eaf65640a260de217db912b14a2e7d948265 /modules/gdscript/gdscript_analyzer.cpp
parentf382a2b59bb9606f958ccaf7be7ac98f45607c9f (diff)
downloadredot-engine-bbb21c3fd57af58f458b73fce16f2754e6408a53.tar.gz
Fix type adjustment skipped when value is considered both not hard and not variant
Diffstat (limited to 'modules/gdscript/gdscript_analyzer.cpp')
-rw-r--r--modules/gdscript/gdscript_analyzer.cpp24
1 files changed, 10 insertions, 14 deletions
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp
index fc2e6e94f3..686e27b2ae 100644
--- a/modules/gdscript/gdscript_analyzer.cpp
+++ b/modules/gdscript/gdscript_analyzer.cpp
@@ -2259,30 +2259,26 @@ void GDScriptAnalyzer::reduce_assignment(GDScriptParser::AssignmentNode *p_assig
}
p_assignment->set_datatype(op_type);
- if (!assignee_type.is_variant() && assigned_value_type.is_hard_type()) {
+ if (assignee_type.is_hard_type() && !assignee_type.is_variant() && op_type.is_hard_type()) {
if (compatible) {
compatible = is_type_compatible(assignee_type, op_type, true, p_assignment->assigned_value);
if (!compatible) {
- if (assignee_type.is_hard_type()) {
- // Try reverse test since it can be a masked subtype.
- if (!is_type_compatible(op_type, assignee_type, true, p_assignment->assigned_value)) {
- push_error(vformat(R"(Cannot assign a value of type "%s" to a target of type "%s".)", assigned_value_type.to_string(), assignee_type.to_string()), p_assignment->assigned_value);
- } else {
- // TODO: Add warning.
- mark_node_unsafe(p_assignment);
- p_assignment->use_conversion_assign = true;
- }
+ // Try reverse test since it can be a masked subtype.
+ if (!is_type_compatible(op_type, assignee_type, true)) {
+ push_error(vformat(R"(Cannot assign a value of type "%s" to a target of type "%s".)", assigned_value_type.to_string(), assignee_type.to_string()), p_assignment->assigned_value);
} else {
- // TODO: Warning in this case.
+ // TODO: Add warning.
mark_node_unsafe(p_assignment);
+ p_assignment->use_conversion_assign = true;
}
}
} else {
push_error(vformat(R"(Invalid operands "%s" and "%s" for assignment operator.)", assignee_type.to_string(), assigned_value_type.to_string()), p_assignment);
}
- }
-
- if (assignee_type.has_no_type() || assigned_value_type.is_variant()) {
+ } else if (assignee_type.is_hard_type() && !assignee_type.is_variant()) {
+ mark_node_unsafe(p_assignment);
+ p_assignment->use_conversion_assign = true;
+ } else {
mark_node_unsafe(p_assignment);
if (assignee_type.is_hard_type() && !assignee_type.is_variant()) {
p_assignment->use_conversion_assign = true;