Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
gh-133357: FixSyntaxError
carret location on invalid starred exprs#133455
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Yeah I don't want to over complicate this because not only is very easy to make it slower for no real gain in most cases but the more complex the rules are the more edge cases they will have and with peg that can also affect other rules |
Agreed on the point about complexity. Is this an improvement over the status quo though? |
@lysnikolaou are you ok if we go with this? |
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.
Can we add a test that actually verifys the location to prevent a future regression?
Adding such test can be done, but is rather hard to do, since there's no infrastructure for such tests as far as I know. |
We normally either add them in test exceptions or test syntax |
I proposed a test in a PR against your branch. |
lysnikolaou commentedMay 5, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I'm okay to go with this if everyone else agrees, but I'm not convinced this is clearer. The caret should point to the first character that does not adhere to our syntax and this breaks that assumption. The current caret position is not random. It actually points to the correct place. In the above examples@sobolevn showed, if A[*(1,)] |
@lysnikolaou yes, this is a good point. Maybe we can come up with a better solution? Do you have an idea about what we can do? |
Ideally we would be able to place tildes below the whole expression and a caret below the position that breaks the syntax. I don't think we have that in the parser though and the complexity would be too much. Maybe just keep this as is? |
vitaldmit commentedMay 9, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@lysnikolaou I think it's better just keep this as is. It's cleaner and clearer. There is no need to make tildes and complicate the code. |
Ok, lets keep it as is :) |
Maybe a test and link to this discussion would be good to prevent this changing yet again? |
Uh oh!
There was an error while loading.Please reload this page.
I went with the simplest possible change:

Now carret always points to the star itself.
Why?
RAISE_SYNTAX_ERROR_KNOWN_RANGE
requires the second argument, it is rather hard to match. Because simplea='*' b=expression
does not work. Because, for example,(1:2)
is not a validexpression
it is aslice
in()
.starred_expressions
also seems rather hard:So, I decided to keep it simple.
Invalid star expression
#133357