Repository navigation
fix(ts): fields written out of declaration order evaluate as written - #49
Conversation
Quest-Claim: a8df4e3f979f3b49
Enum variants, positional structs given by index, struct update syntax on a positional struct, and `Range` (built, looped over, or sliced with) now spill the fields written before one they follow, as named structs already did. A reordered aggregate is no longer `simple`, so a ternary never hoists its fields. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: 4930e23
No actionable bugs found. Sharing declaration-order lowering across aggregates and ranges is a sound simplification. Spilling the prefix preserves written evaluation order while leaving the ordered tail inline; marking reordered aggregates non-simple prevents conditional-arm spills from escaping their branch. Fixtures cover side effects, mutable reads, positional struct updates, conditional execution, range construction, loops and slicing.
Verification: GitHub-only static inspection of the complete patch, operand/spill machinery and generated fixtures. I did not run differential tests, compilation or benchmarks. The documented Range struct-update limitation predates this change and is not a new finding.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
…rder # Conflicts: # quest/m2/README.md
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1e9123fa2c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: 181c51d
No new actionable bugs found. The independently reported receiver-ordering bug #49 (comment) is fixed: range_bounds saves earlier operands before emitting bound statements for slicing and copy_within. Buffering those statements centrally is a focused solution, and the logging-receiver fixture captures the ordering.
Verification: static inspection of the incremental patch, both callers, spill helper and generated fixture. No compilation or differential tests run. Previously documented Range struct-update limitations remain outside this fix.
|
Merge summary:
(written by Opus 5.5) |
Regenerates the snapshots for the cases #48 and #49 added, and names `!` and `()` in a suffix (`pass$never`), which printed as an empty part. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
Problem
The THIR lowering put an aggregate's fields in declaration order without keeping the order the source evaluates them, so a variant like
Shape::Line { 1: f(), 0: g() }rang()first. The same held for positional structs given by index, struct update syntax on a positional struct (the base was read before the fields that change it), andRange { end, start }, whether built, looped over withfor, or used to slice. Named structs already spilled when they reordered. The MIR lowering was already correct.Approach
Body::declared, puts written fields in declaration order and spills every non-constant value that would otherwise run after one written later. Only the longest tail already in order stays inline.Rangeconstruction andrange_bounds(slicing) use it. A class with named fields keeps its written-order object literal.forloop over a writtenRangeevaluates its fields as written, spillingendand what comes before it.simpleis false for a reordered aggregate, so aniformatchno longer becomes a ternary whose arm hoists spills.langfixture gainsshapes::order, whose field expressions log as they run, checked against native Rust under both lowerings (lang,lang_mir). Before the fix it failed under THIR on every case except the named struct and passed under MIR.Impact
Alternatives
Follow-ups
operands(a later field had statements) gets spilled again asfield. That's correct but redundant. Rare, and gone once MIR is the only lowering.Range { start, ..r }(struct update on a stdRange) drops its base silently inadt_exprand panics the driver in aforloop. Filed as Struct update on a std range in this PR.🤖 Generated with Claude Code
https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
(written by Opus 5.5)