diff options
author | cdemirer <41021322+cdemirer@users.noreply.github.com> | 2021-12-27 03:32:22 +0800 |
---|---|---|
committer | cdemirer <41021322+cdemirer@users.noreply.github.com> | 2021-12-27 03:32:22 +0800 |
commit | 067b4c8c0715014ae6b61f6e4cb4e807c7e9be4e (patch) | |
tree | 2f087ee2e6635516a747fc4684206af02a14e83d /modules/gdscript/gdscript_analyzer.cpp | |
parent | 28174d531b7128f0281fc2b88da2f4962fd3513e (diff) |
Fix type mutation upon compound assignment
Diffstat (limited to 'modules/gdscript/gdscript_analyzer.cpp')
-rw-r--r-- | modules/gdscript/gdscript_analyzer.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index 7b64c0564e..88789d1ce3 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -1834,13 +1834,14 @@ void GDScriptAnalyzer::reduce_assignment(GDScriptParser::AssignmentNode *p_assig push_error("Cannot assign a new value to a constant.", p_assignment->assignee); } - if (!assignee_type.is_variant() && assigned_value_type.is_hard_type()) { - bool compatible = true; - GDScriptParser::DataType op_type = assigned_value_type; - if (p_assignment->operation != GDScriptParser::AssignmentNode::OP_NONE) { - op_type = get_operation_type(p_assignment->variant_op, assignee_type, assigned_value_type, compatible, p_assignment->assigned_value); - } + bool compatible = true; + GDScriptParser::DataType op_type = assigned_value_type; + if (p_assignment->operation != GDScriptParser::AssignmentNode::OP_NONE) { + op_type = get_operation_type(p_assignment->variant_op, assignee_type, assigned_value_type, compatible, p_assignment->assigned_value); + } + p_assignment->set_datatype(op_type); + if (!assignee_type.is_variant() && assigned_value_type.is_hard_type()) { if (compatible) { compatible = is_type_compatible(assignee_type, op_type, true); if (!compatible) { |