1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Core: Fix operator[] for typed dictionaries

This commit is contained in:
Thaddeus Crews
2024-09-10 08:56:53 -05:00
parent 83d54ab2ad
commit b3d7960df4
7 changed files with 85 additions and 47 deletions

View File

@@ -0,0 +1,7 @@
func get_key() -> Variant:
return "key"
func test():
var typed: Dictionary[int, int]
typed[get_key()] = 0
print('not ok')

View File

@@ -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]'.

View File

@@ -0,0 +1,7 @@
func get_value() -> Variant:
return "value"
func test():
var typed: Dictionary[int, int]
typed[0] = get_value()
print("not ok")

View File

@@ -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]'.