Skip to content
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

name 'state' conflict with Python3 runtime. #4312

Merged
merged 1 commit into from
Jul 28, 2024

Conversation

cyqw
Copy link
Contributor

@cyqw cyqw commented Jun 13, 2023

This PR fixes #4291

This change add keyword tests.
add function names in parser as reserved keywords for targets.
use rule.escapedName instead rule.name in php.stg

@cyqw cyqw force-pushed the rule_name_conflict_in_python3 branch from 6a129f1 to 75fbbe6 Compare June 13, 2023 23:25
@ericvergnaud
Copy link
Contributor

Hi,
thanks for this.
Unfortunately it's very likely that some developers are relying on ctx.state (a typical usage scenario is code completion).
The proposed refactoring would break their code. Plus it doesn't solve the problem, rather it moves it (now I can't use _state as a rule name).
I'm afraid the only reasonable solution here is to disallow usage of state as a rule name...

Copy link
Member

@KvanTTT KvanTTT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix is incorrect. Please add state to Python3 and Python2 reservedWords list without touching runtime files.

Also, it looks like state should be added to JavaScript, TypeScript and Dart reservedWords because CI tests are red: https://github.com/antlr/antlr4/actions/runs/5261330620/jobs/9509322855?pr=4312

@cyqw cyqw force-pushed the rule_name_conflict_in_python3 branch from 75fbbe6 to 3706099 Compare June 15, 2023 22:28
@cyqw
Copy link
Contributor Author

cyqw commented Jun 15, 2023

I think add the name of function or attribute of Parser, lexer to reservedWords is not a good idea.
The functions or attributes of parser, lexer should not expose to generated parser, lexer directly by inherit except some functions can be override.
The parser should be split, one is the interface of generated parser, other one is the implement of basic parser, it is a member of generated parser.

@cyqw cyqw force-pushed the rule_name_conflict_in_python3 branch 6 times, most recently from 5f567f2 to 189c767 Compare June 29, 2023 14:41

Verified

This commit was signed with the committer’s verified signature.
renovate-bot Mend Renovate
Signed-off-by: cyqw <cyqw@163.com>
@cyqw cyqw force-pushed the rule_name_conflict_in_python3 branch from 189c767 to cbffcaf Compare June 29, 2023 15:05
@cyqw
Copy link
Contributor Author

cyqw commented Jun 30, 2023

This fix is incorrect. Please add state to Python3 and Python2 reservedWords list without touching runtime files.

Also, it looks like state should be added to JavaScript, TypeScript and Dart reservedWords because CI tests are red: https://github.com/antlr/antlr4/actions/runs/5261330620/jobs/9509322855?pr=4312

@KvanTTT @ericvergnaud please review the new changes, thanks

@KvanTTT
Copy link
Member

KvanTTT commented Jul 19, 2023

Sorry, I don't review MR in this repository since I don't have maintainer rights and I can't merge requests. I'm not sure my effort is worth since it's unclear whether a request will be merged or not.

@ericvergnaud
Copy link
Contributor

@parrt blessed

@ericvergnaud
Copy link
Contributor

@parrt kind reminder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some rule names cause runtime errors in Python target
4 participants