Repository navigation
Conversation
`*` bound tighter than `.`, `(` and `[`: `[*a.b(c).d]` parsed as an
attribute whose object was `list_splat`, because a splat pattern was
itself a primary expression. A starred expression is now an expression
over a whole primary expression, so `[*a.b]`, `{*a.b}` and
`x = *f(), y` get the same `list_splat` shape as `f(*a.b)`.
The `Lists` corpus test expected the old shape and is updated.
Fixes tree-sitter#314
`type(x).y = 1` parsed as a `type_alias_statement` with no error, because the left side of an alias accepted any type. PEP 695 only allows a name, optionally with type parameters, so the left side is now an identifier or a generic type. That makes the conflict with `primary_expression` unnecessary, and `type(x).y = 1` and `type(x)[0] = 1` parse as assignments. Fixes tree-sitter#321
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #314
Fixes #321
Two separate commits; happy to split them into two PRs if you prefer.
1. Splat binds to the whole operand (#314)
[*a.b(c).d]parsed as anattributewhose object was alist_splat, because a splat pattern was itself aprimary_expression. A starred expression is now an expression over a wholeprimary_expression, so[*a.b],{*a.b}andx = *f(), yget the samelist_splatshape thatf(*a.b)already had.The existing
Listscorpus test expected the old (wrong) tree for[*a.b],[*a()]etc., so its expected output is updated. This is a correction of the test, not a relaxation. A Sets case was added.list_splatmoves from aprimary_expressionsubtype to anexpressionsubtype, which changesnode-types.json.2. Only a name on the left of a type alias (#321)
type(x).y = 1andtype(x)[0] = 1parsed as atype_alias_statementwith no ERROR node. PEP 695 only allows a name, optionally with type parameters, so the left side is now anidentifierorgeneric_type. That removes the need for the[type_alias_statement, primary_expression]conflict.type X = int,type X[T] = ...,type = 1andprint(type)parse as before.Testing
tree-sitter test: 122 passed, 0 failed.parser.cregenerated with tree-sitter CLI 0.25.9, the version already used in the repo; the large diff is state renumbering.🤖 Generated with Claude Code