Skip to content

Move starred expression checks out of parser#1158

Merged
slozier merged 1 commit intoIronLanguages:masterfrom
slozier:starred
Apr 2, 2021
Merged

Move starred expression checks out of parser#1158
slozier merged 1 commit intoIronLanguages:masterfrom
slozier:starred

Conversation

@slozier
Copy link
Copy Markdown
Contributor

@slozier slozier commented Apr 1, 2021

Moves the starred expression checks out of parser which resolves the following:

import ast
try:
    ast.parse("*a")
except SyntaxError:
    assert False

@slozier slozier force-pushed the starred branch 3 times, most recently from 50c9382 to 65eae72 Compare April 1, 2021 23:03
@slozier slozier marked this pull request as ready for review April 1, 2021 23:57
@slozier slozier requested a review from BCSharp April 1, 2021 23:57
@slozier
Copy link
Copy Markdown
Contributor Author

slozier commented Apr 2, 2021

@BCSharp do you think this seems like a reasonable approach to post-parsing syntax checks?

Copy link
Copy Markdown
Member

@BCSharp BCSharp left a comment

Choose a reason for hiding this comment

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

I think it is a good approach. My only concern was about the ordering of the checks (it comes after namebinding syntax errors are reported), but it appears this is exactly what CPython does as well, so all is well.

A few other things that caught my eye, I'm pretty sure you know this, but just for the record:

  1. Going through compile(ast.parse(...), ...) does not work, even for valid cases; I assume this is for another PR, maybe a one that finishes off #686?
  2. Starting from Python 3.5, the error message "can use starred expression only as assignment target" is replaced by "can't use starred expression here", I assume this will get changed in #1153?

@slozier
Copy link
Copy Markdown
Contributor Author

slozier commented Apr 2, 2021

Going through compile(ast.parse(...), ...) does not work, even for valid cases; I assume this is for another PR, maybe a one that finishes off #686?

Ah, I knew there was a starred expression issue somewhere, good catch. I guess this solved half the issue. Will take a look at the second half in a separate PR (if I don't forget about it).

Starting from Python 3.5, the error message "can use starred expression only as assignment target" is replaced by "can't use starred expression here", I assume this will get changed in #1153?

Indeed, 3.5 will change a bunch of things in this walker, but it seemed like a good idea to work this out separately from the other PR.

@slozier slozier merged commit 3f358a4 into IronLanguages:master Apr 2, 2021
@slozier slozier deleted the starred branch April 2, 2021 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants