-
-
Notifications
You must be signed in to change notification settings - Fork 21k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Core: Fix
operator[]
for typed dictionaries
- Loading branch information
Showing
5 changed files
with
34 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...s/gdscript/tests/scripts/analyzer/errors/typed_dictionary_assign_differently_typed_key.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
func get_key(): | ||
return "key" | ||
|
||
func test(): | ||
var typed: Dictionary[int, int] | ||
typed[get_key()] = 0 | ||
print('not ok') |
2 changes: 2 additions & 0 deletions
2
.../gdscript/tests/scripts/analyzer/errors/typed_dictionary_assign_differently_typed_key.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
Invalid index type "String" for a base of type "Dictionary[int, int]". |
7 changes: 7 additions & 0 deletions
7
...es/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_key.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
func get_key() -> Variant: | ||
return "key" | ||
|
||
func test(): | ||
var typed: Dictionary[int, int] | ||
typed[get_key()] = 0 | ||
print('not ok') |
5 changes: 5 additions & 0 deletions
5
...s/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_key.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
GDTEST_RUNTIME_ERROR | ||
>> ERROR | ||
>> Method/function failed. Returning: false | ||
>> Attempted to use a variable of type 'String' into a TypedDictionary.Key of type 'int'. | ||
not ok |