diff options
Diffstat (limited to 'modules')
5 files changed, 42 insertions, 12 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(); diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 9e347eed5a..ca430b0f72 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -3605,8 +3605,12 @@ bool GDScriptParser::export_annotations(const AnnotationNode *p_annotation, Node variable->export_info.type = Variant::OBJECT; variable->export_info.hint = PROPERTY_HINT_RESOURCE_TYPE; variable->export_info.hint_string = export_type.native_type; + } else if (ClassDB::is_parent_class(export_type.native_type, SNAME("Node"))) { + variable->export_info.type = Variant::OBJECT; + variable->export_info.hint = PROPERTY_HINT_NODE_TYPE; + variable->export_info.hint_string = export_type.native_type; } else { - push_error(R"(Export type can only be built-in, a resource, or an enum.)", variable); + push_error(R"(Export type can only be built-in, a resource, a node, or an enum.)", variable); return false; } break; diff --git a/modules/gdscript/gdscript_vm.cpp b/modules/gdscript/gdscript_vm.cpp index 16a8e728e4..1d56dae982 100644 --- a/modules/gdscript/gdscript_vm.cpp +++ b/modules/gdscript/gdscript_vm.cpp @@ -1897,7 +1897,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a VariantInternal::initialize(ret, Variant::OBJECT); Object **ret_opaque = VariantInternal::get_object(ret); method->ptrcall(base_obj, argptrs, ret_opaque); - VariantInternal::object_assign(ret, *ret_opaque); // Set so ID is correct too. + VariantInternal::update_object_id(ret); #ifdef DEBUG_ENABLED if (GDScriptLanguage::get_singleton()->profiling) { diff --git a/modules/gdscript/tests/scripts/runtime/features/chain_assignment_works.gd b/modules/gdscript/tests/scripts/runtime/features/chain_assignment_works.gd new file mode 100644 index 0000000000..d2f3a3e18f --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/chain_assignment_works.gd @@ -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) diff --git a/modules/gdscript/tests/scripts/runtime/features/chain_assignment_works.out b/modules/gdscript/tests/scripts/runtime/features/chain_assignment_works.out new file mode 100644 index 0000000000..5e7ccf534a --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/chain_assignment_works.out @@ -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)] |