From 9e5fdbc79d4e6666f2ab184e7721e87c7411eb40 Mon Sep 17 00:00:00 2001 From: kobewi Date: Tue, 5 Oct 2021 02:48:33 +0200 Subject: [PATCH] Fix LUA-style assignment in Dictionary --- core/variant/variant_setget.cpp | 3 ++- modules/gdscript/tests/scripts/runtime/features/lua_assign.gd | 4 ++++ .../gdscript/tests/scripts/runtime/features/lua_assign.out | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 modules/gdscript/tests/scripts/runtime/features/lua_assign.gd create mode 100644 modules/gdscript/tests/scripts/runtime/features/lua_assign.out diff --git a/core/variant/variant_setget.cpp b/core/variant/variant_setget.cpp index 3bba68d75ed..4abb51ca7c3 100644 --- a/core/variant/variant_setget.cpp +++ b/core/variant/variant_setget.cpp @@ -239,7 +239,8 @@ void Variant::set_named(const StringName &p_member, const Variant &p_value, bool *v = p_value; r_valid = true; } else { - r_valid = false; + VariantGetInternalPtr::get_ptr(this)->operator[](p_member) = p_value; + r_valid = true; } } else { diff --git a/modules/gdscript/tests/scripts/runtime/features/lua_assign.gd b/modules/gdscript/tests/scripts/runtime/features/lua_assign.gd new file mode 100644 index 00000000000..c9b5f8481e8 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/lua_assign.gd @@ -0,0 +1,4 @@ +func test(): + var dict = {} + dict.test = 1 + print(dict.test) diff --git a/modules/gdscript/tests/scripts/runtime/features/lua_assign.out b/modules/gdscript/tests/scripts/runtime/features/lua_assign.out new file mode 100644 index 00000000000..a7f1357bb23 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/lua_assign.out @@ -0,0 +1,2 @@ +GDTEST_OK +1