You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adding to a typed dictionary using operator[] allows adding keys/values of different types, if the types aren't known until run time, or if the typed dictionary is passed into a function that takes an untyped dictionary. In both cases, using get_or_add catches the difference and gives an error.
Steps to reproduce
Create a new project, and add code below to main scene:
As GDScript is a gradually typed language, is there a need to implement this type inference? Would we expect this dictionary's type to not be cast to the untyped dictionary? As get_or_add verifies types during runtime, it might make more sense to prefer that when potentially using mixed types. I'm all for increased type inference accuracy though.
Oh shoot, good catch! This was an erroneous regression in one of the rebases of the typed dictionary PR. Making a fix and putting up a testcase to make sure this won't happen again 👍
Tested versions
Latest master v4.4.dev.custom_build [2124995]
System information
Windows 10
Issue description
Adding to a typed dictionary using
operator[]
allows adding keys/values of different types, if the types aren't known until run time, or if the typed dictionary is passed into a function that takes an untyped dictionary. In both cases, usingget_or_add
catches the difference and gives an error.Steps to reproduce
Create a new project, and add code below to main scene:
This prints
{ "test1": 1, "test2": 2 }
without giving any errorsMinimal reproduction project (MRP)
N/A
The text was updated successfully, but these errors were encountered: