Skip to content

fix: parse splats in return expression lists - #354

Open
JarvisDing-sdu wants to merge 1 commit into
tree-sitter:masterfrom
JarvisDing-sdu:fix/return-tuple-splats
Open

JarvisDing-sdu wants to merge 1 commit into
tree-sitter:masterfrom
JarvisDing-sdu:fix/return-tuple-splats

Conversation

@JarvisDing-sdu

Copy link
Copy Markdown

Fix parsing of valid starred expressions in return expression lists.

Previously, return values such as return 1, *[None] and return 1, *([None] * 5) produced an ERROR node instead of a return_statement.

Add a return-specific expression-list rule that accepts list_splat, while preserving the public CST node name expression_list and leaving the general expression-list grammar unchanged.

Add corpus coverage for simple, parenthesized/binary, and multiple starred return values.

Tests:

  • npx tree-sitter test
  • npm run lint
  • npm test
  • go test ./bindings/go
  • python -m pytest bindings/python/tests

Rust binding tests were not run because cargo is unavailable in the test environment.

@wetneb

wetneb commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

I wonder if there is anything special about such expressions appearing in a return statement?
As far as I can tell, this is valid Python code as well, which would be worth parsing too:

x = 1, *([None] * 5)
print(x)

Note: I'm not a maintainer here, and this grammar seems to be mostly unmaintained (as many other grammars in this organizations), but we are maintaining a fork tree-sitter-python-orchard, where I would integrate your contribution.

@wetneb

wetneb commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

After reviewing the other PRs in this repo, I found #320 which seems to address the problem I mentioned above, so I'd recommend just using that PR instead. I have integrated it in our fork, so feel free to switch to that (if you can't for one reason or another, I'm interested to hear what is blocking you).

This branch has not been deployed

No deployments
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