Skip to content

yeast: Add explicit locationless nodes - #22959

Open
tausbn wants to merge 2 commits into
mainfrom
tausbn/yeast-explicit-locationless-nodes
Open

tausbn wants to merge 2 commits into
mainfrom
tausbn/yeast-explicit-locationless-nodes

Conversation

@tausbn

@tausbn tausbn commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

These are needed for Python, where expression contexts (Store/Load/Param/Del) are AST nodes that are explicitly locationless. Thus, for these the default heuristic of giving them an empty range at the start of the enclosing node is not that useful (and the subsequent unioning of child ranges is quite detrimental).

We therefore need a way to specify that some nodes are locationless, and I ended up with the syntax location: none. I briefly considered writing this as location: {None} instead, but unfortunately rustc does not accept this as the type of None is not fully specified. It would have to be written as None::<OutputId> which is quite ugly.

Finally, having explicit location overrides and location: none at the same time is an error (that we discover during parsing).

@tausbn tausbn added the no-change-note-required This PR does not need a change note label Oct 30, 2026
@tausbn tausbn changed the title yeast: Add explicit locationless nodes WIP yeast: Add explicit locationless nodes Oct 30, 2026
These are needed for Python, where expression contexts
(Store/Load/Param/Del) are AST nodes that are explicitly locationless.
Thus, for these the default heuristic of giving them an empty range at
the start of the enclosing node is not that useful (and the subsequent
unioning of child ranges is quite detrimental)..

We therefore need a way to specify that some nodes are locationless, and
I ended up with the syntax `location: none`. I briefly considered
writing this as `location: {None}` instead, but unfortunately `rustc`
does not accept this as the type of `None` is not fully specified. It
would have to be written as `None::<OutputId>` which is quite ugly.

Finally, having explicit location overrides and `location: none` at the
same time is an error (that we discover during parsing).
@tausbn
tausbn force-pushed the tausbn/yeast-explicit-locationless-nodes branch from 2b71b27 to dae1d88 Compare October 30, 2026 15:24
@tausbn
tausbn requested a max review from Copilot October 30, 2026 15:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Remaining findings identify incomplete documentation of none restrictions and missing nested-node tests confirming that locationless children retain None without widening parent ranges.

2 open issues
What changed in this PR

Adds explicit locationless synthetic nodes to YEAST, supporting cases such as Python expression-context nodes where inferred source ranges are inappropriate.

Changes:

  • Introduces location: none and rejects combinations with other location overrides.
  • Clears inferred ranges and prevents locationless rule results from inheriting the matched input range.
  • Documents the syntax and adds parser and root-location tests.
File Description
shared/​yeast/​tests/​test.rs Tests that a returned node remains locationless.
shared/​yeast/​src/​lib.rs Adds source-range clearing for synthetic nodes.
shared/​yeast/​src/​build.rs Prevents explicitly locationless nodes from inheriting ranges.
shared/​yeast/​doc/​yeast.md Documents location: none.
shared/​yeast-macros/​src/​template_parse.rs Parses the syntax, rejects conflicting fields, and adds tests.
shared/​yeast-macros/​src/​lower.rs Generates locationless-node construction calls.
shared/​yeast-macros/​src/​lib.rs Adds the syntax to macro documentation.
shared/​yeast-macros/​src/​ast.rs Represents locationless metadata in the macro AST.

Review effort: Max

Comment thread shared/yeast/doc/yeast.md Resolved
Comment thread shared/yeast/tests/test.rs Resolved
Clarified usage of `location: none` for synthetic nodes and its effects on parent node ranges.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@tausbn
tausbn marked this pull request as ready for review October 30, 2026 16:35
@tausbn
tausbn requested a review from a team as a code owner October 30, 2026 16:35

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

documentation no-change-note-required This PR does not need a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants