-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
bpo-43914: Highlight invalid ranges in SyntaxErrors #25525
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
Conversation
@lysnikolaou Could you take a look so we can get this before feature freeze? Some notes:
|
@pablogsal Yup, I'll have a look tomorrow morning. |
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.
Really really great work! 🚀
I've left a couple of comments/questions.
Grammar/python.gram
Outdated
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "Generator expression must be parenthesized") } | ||
| a=args ',' '*' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "iterable argument unpacking follows keyword argument unpacking") } | ||
| a=expression b=for_if_clauses ',' [args | expression for_if_clauses] { | ||
RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, asdl_seq_GET(b, b->size-1)->target, "Generator expression must be parenthesized") } |
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.
Could we use _PyPegen_seq_last_item
here?
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.
Yeah, but it won't be shorter because _PyPegen_seq_last_item
is generic and does type erasure so we need to recast to get the target
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.
I think I can make it more readable with some macros
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.
Check out commit 6f01d08
I also have some recommendations for the new error ranges. For example I'd prefer:
over
I guess, it'd be better to merge this and I'll open another PR to discuss these there. Thoughts? |
Yeah, that one is especially tricky because it (not with what you suggest but I have seen it happen) can make the parser advance too much and the error will be reported too far away from the '=' sign. |
Yup, I can see that happening. |
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.
Let's go! 🎉
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.
Only a nit.
Co-authored-by: Lysandros Nikolaou <[email protected]>
🤖 New build scheduled with the buildbot fleet by @pablogsal for commit 4e8bb50 🤖 If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again. |
🤖 New build scheduled with the buildbot fleet by @pablogsal for commit 4e8bb50 🤖 If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again. |
@pablogsal: Please replace |
https://bugs.python.org/issue43914