-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Make GDScript allow some keywords as identifiers #8217
Make GDScript allow some keywords as identifiers #8217
Conversation
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.
Looks good so far, I'd keep the old error messages though.
modules/gdscript/gd_parser.cpp
Outdated
|
||
_set_error("Expected identifier for argument."); | ||
_set_error("Expected literal for argument."); |
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.
literal? It's still an identifier. It's just that the identifier might have the same name as a keyword, it's an identifier nonetheless.
Usually "constant values" (like a string or a number) are called literals. I'd keep the old error message.
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.
Ookay, would revert that part.
modules/gdscript/gd_parser.cpp
Outdated
if (tokenizer->get_token() != GDTokenizer::TK_IDENTIFIER) { | ||
_set_error("Expected identifier for setter function after 'notify'."); | ||
if (!tokenizer->is_token_literal()) { | ||
_set_error("Expected literal for setter function after 'setget'."); |
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.
Old relict? 😄 This is more descriptive, cool. But I'd still change it to back to identifier.
6382a28
to
7e08b44
Compare
@karroffel Fixed |
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.
👍 Looks good!
Since we now prevent naming variables like properties of the base class (e.g. if you name a member variable I think Godot users will learn to live with this limitation, it might be frustrating a couple times, but then you make do and benefit from the consistency. |
@akien-mga Still, I think we should allow calling methods like |
Well if we disallow creating them, it makes no sense to allow calling them, since the situation would never arise. |
@akien-mga That's wrong, since we can just have a GDNative or C# script which would be free to register them... |
So what should we do here (apart from a needed rebase)? |
I'm OK with this change as it fixes some current problems, like String.match() that can't be called. Creating functions with keywords as names should be documented to explain the need of the |
@bojidar-bg You've got the go from @reduz, albeit you need to add some more documentation (and rebase):
|
7e08b44
to
e28d4d4
Compare
Ok, rebased, now I would have to think how to include the doc. 😃 Edit: done |
Fixes godotengine#8085 Added some comments around the use of is_token_literal, as discussed.
e28d4d4
to
1936e1d
Compare
we really should update all docs..
…On Sun, Jul 23, 2017 at 5:36 PM, Bojidar Marinov ***@***.***> wrote:
(Bump, done, updating for email notifications)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#8217 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AF-Z26NxyYnWoqKhWrR5YRMG8wlUkBsyks5sQ66ygaJpZM4Mv8uM>
.
|
Let's give @bojidar-bg some time to try a fix :) |
Fixes #8085
Here is a test script:
Here are some things that won't work with this changes:
And here are some strange ones that would work