diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2022-01-10 17:12:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-10 17:12:34 +0100 |
commit | cc7f6340664b5f4a902e54b222840bca39041451 (patch) | |
tree | 74c4c3d3425784d84630221a854df9cc475156ae /modules/gdscript/gdscript_analyzer.cpp | |
parent | c8b4fe3b8d44a3e7009500d919b2ab137690c669 (diff) | |
parent | 067b4c8c0715014ae6b61f6e4cb4e807c7e9be4e (diff) | |
download | redot-engine-cc7f6340664b5f4a902e54b222840bca39041451.tar.gz |
Merge pull request #56260 from cdemirer/fix-type-mutation-upon-assignment-with-operation
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 0bf4f5e1f1..9d474cd13a 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -1868,13 +1868,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) { |