summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClay John <claynjohn@gmail.com>2024-10-17 16:53:11 -0700
committerGitHub <noreply@github.com>2024-10-17 16:53:11 -0700
commite50b864b642fdda40278b0b1967ca7c1e3af762c (patch)
treecebacc1756a82e237cb2ce6000ed81d994d1f195
parentacc3786db2777e31d83c545781246c408bc4c4c8 (diff)
parent0bc59c78de9ebc162bde4538f9c68e35b4509403 (diff)
downloadredot-engine-e50b864b642fdda40278b0b1967ca7c1e3af762c.tar.gz
Merge pull request #98085 from dalexeev/gds-fix-typed-dict-static-default-init
GDScript: Add missing static default initialization for typed dictionaries
-rw-r--r--modules/gdscript/gdscript.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp
index 7b9aa70686..18f2ccc455 100644
--- a/modules/gdscript/gdscript.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -693,10 +693,16 @@ void GDScript::_static_default_init() {
continue;
}
if (type.builtin_type == Variant::ARRAY && type.has_container_element_type(0)) {
+ const GDScriptDataType element_type = type.get_container_element_type(0);
Array default_value;
- const GDScriptDataType &element_type = type.get_container_element_type(0);
default_value.set_typed(element_type.builtin_type, element_type.native_type, element_type.script_type);
static_variables.write[E.value.index] = default_value;
+ } else if (type.builtin_type == Variant::DICTIONARY && type.has_container_element_types()) {
+ const GDScriptDataType key_type = type.get_container_element_type_or_variant(0);
+ const GDScriptDataType value_type = type.get_container_element_type_or_variant(1);
+ Dictionary default_value;
+ default_value.set_typed(key_type.builtin_type, key_type.native_type, key_type.script_type, value_type.builtin_type, value_type.native_type, value_type.script_type);
+ static_variables.write[E.value.index] = default_value;
} else {
Variant default_value;
Callable::CallError err;