Merge pull request #62485 from cdemirer/fix-set-chain-jump-if-shared

Fix chain assignment bug with jump_if_shared
This commit is contained in:
Rémi Verschelde 2022-06-28 19:13:35 +02:00 committed by GitHub
commit f6072c9c98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 10 deletions

View file

@ -1059,23 +1059,23 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
bool known_type = assigned.type.has_type;
bool is_shared = Variant::is_type_shared(assigned.type.builtin_type);
if (!known_type || !is_shared) {
if (!known_type) {
// Jump shared values since they are already updated in-place.
gen->write_jump_if_shared(assigned);
}
if (known_type && !is_shared) {
if (!info.is_named) {
gen->write_set(info.base, info.key, assigned);
if (info.key.mode == GDScriptCodeGenerator::Address::TEMPORARY) {
gen->pop_temporary();
}
} else {
gen->write_set_named(info.base, info.name, assigned);
}
}
if (!known_type) {
gen->write_end_jump_if_shared();
}
}
if (!info.is_named && info.key.mode == GDScriptCodeGenerator::Address::TEMPORARY) {
gen->pop_temporary();
}
if (assigned.mode == GDScriptCodeGenerator::Address::TEMPORARY) {
gen->pop_temporary();
}

View file

@ -0,0 +1,19 @@
func test():
var dictionary1: Variant = {1:Vector2()}
dictionary1[1].x = 2
var dictionary2: Dictionary = {3:Vector2()}
dictionary2[3].x = 4
var array1: Variant = [[Vector2()]]
array1[0][0].x = 5
var array2: Array = [[Vector2()]]
array2[0][0].x = 6
var array3: Array[Array] = [[Vector2()]]
array3[0][0].x = 7
var transform = Transform3D()
transform.basis.x = Vector3(8.0, 9.0, 7.0)
print(dictionary1)
print(dictionary2)
print(array1)
print(array2)
print(array3)
print(transform)

View file

@ -0,0 +1,7 @@
GDTEST_OK
{1:(2, 0)}
{3:(4, 0)}
[[(5, 0)]]
[[(6, 0)]]
[[(7, 0)]]
[X: (8, 9, 7), Y: (0, 1, 0), Z: (0, 0, 1), O: (0, 0, 0)]