mirror of
https://github.com/godotengine/godot.git
synced 2024-12-27 11:24:59 +08:00
Merge pull request #41062 from ThakeeNathees/unsafe-arithmatic-assignment-bug-fix
GDScript: unsafe arithmetic assignment bug fix
This commit is contained in:
commit
241e709462
@ -1406,23 +1406,25 @@ void GDScriptAnalyzer::reduce_assignment(GDScriptParser::AssignmentNode *p_assig
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool compatible = true;
|
if (!p_assignment->assignee->get_datatype().is_variant() && !p_assignment->assigned_value->get_datatype().is_variant()) {
|
||||||
GDScriptParser::DataType op_type = p_assignment->assigned_value->get_datatype();
|
bool compatible = true;
|
||||||
if (vop != Variant::OP_EQUAL) {
|
GDScriptParser::DataType op_type = p_assignment->assigned_value->get_datatype();
|
||||||
op_type = get_operation_type(vop, p_assignment->assignee->get_datatype(), p_assignment->assigned_value->get_datatype(), compatible);
|
if (vop != Variant::OP_EQUAL) {
|
||||||
}
|
op_type = get_operation_type(vop, p_assignment->assignee->get_datatype(), p_assignment->assigned_value->get_datatype(), compatible);
|
||||||
|
}
|
||||||
if (compatible) {
|
|
||||||
compatible = is_type_compatible(p_assignment->assignee->get_datatype(), op_type, true);
|
if (compatible) {
|
||||||
if (!compatible) {
|
compatible = is_type_compatible(p_assignment->assignee->get_datatype(), op_type, true);
|
||||||
if (p_assignment->assignee->get_datatype().is_hard_type()) {
|
if (!compatible) {
|
||||||
push_error(vformat(R"(Cannot assign a value of type "%s" to a target of type "%s".)", p_assignment->assigned_value->get_datatype().to_string(), p_assignment->assignee->get_datatype().to_string()), p_assignment->assigned_value);
|
if (p_assignment->assignee->get_datatype().is_hard_type()) {
|
||||||
} else {
|
push_error(vformat(R"(Cannot assign a value of type "%s" to a target of type "%s".)", p_assignment->assigned_value->get_datatype().to_string(), p_assignment->assignee->get_datatype().to_string()), p_assignment->assigned_value);
|
||||||
// TODO: Warning in this case.
|
} else {
|
||||||
}
|
// TODO: Warning in this case.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
push_error(vformat(R"(Invalid operands "%s" and "%s" for assignment operator.)", p_assignment->assignee->get_datatype().to_string(), p_assignment->assigned_value->get_datatype().to_string()), p_assignment);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
push_error(vformat(R"(Invalid operands "%s" and "%s" for assignment operator.)", p_assignment->assignee->get_datatype().to_string(), p_assignment->assigned_value->get_datatype().to_string()), p_assignment);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_assignment->assignee->get_datatype().has_no_type() || p_assignment->assigned_value->get_datatype().is_variant()) {
|
if (p_assignment->assignee->get_datatype().has_no_type() || p_assignment->assigned_value->get_datatype().is_variant()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user