summaryrefslogtreecommitdiff
path: root/modules/gdscript/gdscript_compiler.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-06-28 19:13:35 +0200
committerGitHub <noreply@github.com>2022-06-28 19:13:35 +0200
commitf6072c9c98f11797e31a2076d17b580a6c651679 (patch)
tree0525261ea62cc94a154d1f04f7fa44000e6cf654 /modules/gdscript/gdscript_compiler.cpp
parent8cd6127cb8905485f6e27f6e3760df78fb227aa4 (diff)
parenta0608bd8915f69c533cf729f1b091b31a8d933cb (diff)
Merge pull request #62485 from cdemirer/fix-set-chain-jump-if-shared
Fix chain assignment bug with jump_if_shared
Diffstat (limited to 'modules/gdscript/gdscript_compiler.cpp')
-rw-r--r--modules/gdscript/gdscript_compiler.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp
index 1daf8ff7a9..6055d3df33 100644
--- a/modules/gdscript/gdscript_compiler.cpp
+++ b/modules/gdscript/gdscript_compiler.cpp
@@ -1059,22 +1059,22 @@ 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) {
- // Jump shared values since they are already updated in-place.
- gen->write_jump_if_shared(assigned);
- }
- if (known_type && !is_shared) {
+ 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 (!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 (!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();