Skip to content

Yeast: Keep AST iteration order as in ast_types.yml. - #22519

Open
aschackmull wants to merge 1 commit into
github:mainfrom
aschackmull:yeast/keep-child-order
Open

Yeast: Keep AST iteration order as in ast_types.yml.#22519
aschackmull wants to merge 1 commit into
github:mainfrom
aschackmull:yeast/keep-child-order

Conversation

@aschackmull

@aschackmull aschackmull commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

The AST iteration order in the walk function uses ChildrenIter which in turn used the standard iterator from BTreeMap. This meant that the order was dependent on FieldId ordering, which is effectively arbitrary.
This PR keeps the field order from ast_types.yml and 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.

@aschackmull aschackmull added the no-change-note-required This PR does not need a change note label Sep 7, 2026
Copilot AI balanced review requested due to automatic review settings September 7, 2026 09:44
@aschackmull
aschackmull requested a review from a team as a code owner September 7, 2026 09:44

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.

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 Medium severity

New issues introduced by this change (1)
Severity Finding
Medium severity 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 thread shared/yeast/src/lib.rs
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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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