-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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: Unify StringName and String #68747
GDScript: Unify StringName and String #68747
Conversation
I've found no functionality regression. As one would expect, |
a5b8389
to
e7c97d6
Compare
e7c97d6
to
adf976f
Compare
@MewPurPur that performance diff shouldn't be the case, although i did push a new version since you tested |
In order for the last check to pass, godotengine/godot-cpp#930 needs to be merged to solve ambiguous overload errors |
Fait critique, the benchmarks need something to compare to. |
4994dcd
to
0c4b053
Compare
edf69c7
to
c2980b9
Compare
I tested this pr and it seems to 'fix' the match statement, in gd3 this worked match node.get_name():
"test1":
pass
_:
pass And this PR makes this code work again ( Need to do StringName("test1") for the match to work, or String(node.get_name()) without this PR) |
c2980b9
to
b54ffc2
Compare
b54ffc2
to
e79be6c
Compare
I didn't test, but looking at the code it also fixes #68834 |
Thanks! |
I'm not sure if it belongs here, in a separate bug report, or in a feature request, but To me that feels logically related to the unification of StringName and String. |
Also not sure if this belongs here, but: funcs that take String like load() need something like this:
It took me ages to think of using str() |
this change aims to fix #64171 by letting String and StringName be used nearly interchangeably in GDScript
registers all string methods to StringName in
variant_call.cpp
-- So String methods can be used on StringNames ('&"stringname".has("str")' and vice versa)
fills in the gaps between String and StringName in
variant_op.cpp
-- So '"str" in &"stringname"' works and among others
Array will silently coerce Strings and StringNames into each other when typed in any method that takes a variant input
-- So Array acts like they are almost the same type, but silently converts if inserted or anything into a typed Array
-- fixes #63965, all 4 tests return true
other functions in untyped Array will also compare Strings and StringNames
-- fixes #68918
Dictionary now compares String and StringName keys
-- which fixes #62957
lastly, the analyzer will do the same
-- So it doesn't tell you you can't assign Array[String] to Array[StringName]
and the compiler will make an exception in match statements for String and StringName, allowing comparisons
-- which fixes #60145
also added a check for StringName in a couple places (
regex.cpp
andscene_rpc_interface.cpp
)Notes and things to discuss:
is_string()
method..