summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorThaddeus Crews <repiteo@outlook.com>2024-09-10 08:56:53 -0500
committerThaddeus Crews <repiteo@outlook.com>2024-09-12 11:10:17 -0500
commitb3d7960df48f28cc1519a8fd1ad219d0b7dd506c (patch)
tree67cfdd165489950e87032d64458970714c7cc653 /modules
parent83d54ab2ad476ae265b323c2b88f4623b922f4c6 (diff)
downloadredot-engine-b3d7960df48f28cc1519a8fd1ad219d0b7dd506c.tar.gz
Core: Fix `operator[]` for typed dictionaries
Diffstat (limited to 'modules')
-rw-r--r--modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_key.gd7
-rw-r--r--modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_key.out6
-rw-r--r--modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_value.gd7
-rw-r--r--modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_value.out6
4 files changed, 26 insertions, 0 deletions
diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_key.gd b/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_key.gd
new file mode 100644
index 0000000000..2f0b3bd0eb
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_key.gd
@@ -0,0 +1,7 @@
+func get_key() -> Variant:
+ return "key"
+
+func test():
+ var typed: Dictionary[int, int]
+ typed[get_key()] = 0
+ print('not ok')
diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_key.out b/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_key.out
new file mode 100644
index 0000000000..5f6dd7f641
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_key.out
@@ -0,0 +1,6 @@
+GDTEST_RUNTIME_ERROR
+>> SCRIPT ERROR
+>> on function: test()
+>> runtime/errors/typed_dictionary_assign_differently_typed_key.gd
+>> 6
+>> Invalid assignment of property or key 'key' with value of type 'int' on a base object of type 'Dictionary[int, int]'.
diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_value.gd b/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_value.gd
new file mode 100644
index 0000000000..b171159aed
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_value.gd
@@ -0,0 +1,7 @@
+func get_value() -> Variant:
+ return "value"
+
+func test():
+ var typed: Dictionary[int, int]
+ typed[0] = get_value()
+ print("not ok")
diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_value.out b/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_value.out
new file mode 100644
index 0000000000..f766d14261
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_value.out
@@ -0,0 +1,6 @@
+GDTEST_RUNTIME_ERROR
+>> SCRIPT ERROR
+>> on function: test()
+>> runtime/errors/typed_dictionary_assign_differently_typed_value.gd
+>> 6
+>> Invalid assignment of property or key '0' with value of type 'String' on a base object of type 'Dictionary[int, int]'.