bpo-43914: Highlight invalid ranges in SyntaxErrors#25525
bpo-43914: Highlight invalid ranges in SyntaxErrors#25525pablogsal merged 11 commits intopython:masterfrom
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. |
lysnikolaou
left a comment
There was a problem hiding this comment.
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.
Could we use _PyPegen_seq_last_item here?
There was a problem hiding this comment.
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.
I think I can make it more readable with some macros
|
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. |
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
|
🤖 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