-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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
fix access to identifiers that are reserved keywords #62830
fix access to identifiers that are reserved keywords #62830
Conversation
d1e8bc0
to
9440216
Compare
I just realised that instead of creating a variable to mark them as identifier i could directly change the type of the token as the function that gets the identifier from the token isn't using the type but another variable which store the string directly. |
9440216
to
871180b
Compare
caff79a
to
d94bb00
Compare
d94bb00
to
c731385
Compare
I've never fooled around with the tokenizer so I don't feel confident reviewing :) Couple of thoughts though!
|
That seems like a super good idea I'll try to make some but i don't know how to make one so I'll have to look into it.
If it reaches this point and it is not interpreted as an identifier it will just raise an error at the next line. That's why we can here safely modify it. |
c731385
to
9df6244
Compare
I tried looking through the source code some more to try to give this a review but it's a little too much for me atm :) The added test looks good though! From now we can forever make sure that you can use reserved keywords as dictionary keys in Lua-style accessors! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I ran this in debug mode and I do believe that it makes sense! :)
The function changed is already specifically for attribute lookups. The changes make sure that if what comes after the .
is basically text (the call to is_node_name()
), then it should be interpreted as an identifier. Again, only specifically within the context of an attribute lookup, i.e. base.attribute
.
Anything else that isn't text, when is_node_name()
returns false, will still raise an error due to the consume
function wanting to see an identifier there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved by the GDScript team on a PR review meeting.
Thanks for your contribution!
(as discussed, the PR will be ready when more cases will be added to the test)
Marked as a draft until then. Feel free to mark as ready when appropriate. |
9df6244
to
ab9f60d
Compare
It's ready to review! Hurray! 🎉 |
Thanks! |
Fixes #61981
All reserved keywords listed here were interpreted as tokens and returned false when tested with
is_identifier()
. So i made it possible to indicate that a token can be interpreted as an identifier whatever is type. Then inparse_attribute
when we know we want exclusively identifiers i marked keywords as identifiers.