Yeast: Keep AST iteration order as in ast_types.yml. - #22519
Open
aschackmull wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The new traversal and schema-remapping behavior lacks targeted regression coverage.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Balanced
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
shared/yeast/src/lib.rs — Please add a regression test that constructs a node whose declared YAML field order differs from… |
What changed in this PR
Updates YEAST AST traversal to follow field declaration order from ast_types.yml, producing predictable extracted child indices.
Changes:
- Traverses node fields using schema-defined order.
- Preserves field order when schemas are merged.
| File | Description |
|---|---|
shared/yeast/src/lib.rs |
Applies schema field ordering during child traversal. |
shared/yeast-schema/src/schema.rs |
Copies field ordering across schemas. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+352
to
+358
| let field_order = match ast.schema.field_order(node.kind_name()) { | ||
| Some(order) => { | ||
| let mut fields: Vec<FieldId> = order | ||
| .iter() | ||
| .copied() | ||
| .filter(|field| fields.contains_key(field)) | ||
| .collect(); |
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.

The AST iteration order in the
walkfunction usesChildrenIterwhich in turn used the standard iterator fromBTreeMap. This meant that the order was dependent onFieldIdordering, which is effectively arbitrary.This PR keeps the field order from
ast_types.ymland uses that order instead. This affects extraction such that the extracted child indices now are in a predictable order and much more reasonable for the downstream use in default CFG.