Repository navigation
Conversation
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
force-pushed
the
tausbn/yeast-explicit-locationless-nodes
branch
from
October 30, 2026 15:24
2b71b27 to
dae1d88
Compare
Contributor
There was a problem hiding this comment.
🟡 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: noneand 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
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
marked this pull request as ready for review
October 30, 2026 16:35
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.

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 aslocation: {None}instead, but unfortunatelyrustcdoes not accept this as the type ofNoneis not fully specified. It would have to be written asNone::<OutputId>which is quite ugly.Finally, having explicit location overrides and
location: noneat the same time is an error (that we discover during parsing).