-
-
Notifications
You must be signed in to change notification settings - Fork 21k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GDScript 2.0: Using both StringName and String as Dictionary keys at the same time results in unexpected behaviour #62957
Comments
Dictionary internally converts StringNames to Strings, which is likely the cause of this issue. |
Hey @Calinou |
@noobyogi0010 Feel free to open a pull request for this 🙂 |
Since the results are intended, I believe the bug is that the first 2 Dictionaries should have caused a compile-time error ("Key ... was already used in this dictionary") the same way having 2 equal Strings would. On the other hand, maybe those errors should be warnings instead, because you can do the same (without error) using variables at runtime. But I guess that's another issue/proposal. |
Godot version
4.0.alpha11
System information
Windows 10
Issue description
When using both
StringNames
andStrings
asDictionary
keys at the same time, getting the value of that key is inconsistent and appears to be based on the key order in the Dictionary.This is was probably implemeted intentionally to make it less confusing when the dictionary uses StringName keys, but the user uses Strings.
Also when using the
Dictionary.key
syntax it should be probably treated as String as the use of StringNames as keys would be more rare.It should either be forbidden to make two keys with the same text value or make the dictionary interpret these two variations consistently.
Steps to reproduce
Just copy and paste this example into any project:
Minimal reproduction project
No response
The text was updated successfully, but these errors were encountered: