Skip to content

test(codegen): fix number-context coupled-arms test after #11588 + #11589 - #11603

Merged
proggeramlug merged 2 commits into
mainfrom
fix/codegen-number-context-coupled-arms
Sep 28, 2026
Merged

proggeramlug merged 2 commits into
mainfrom
fix/codegen-number-context-coupled-arms

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #11588 and #11589

main is red in perry-codegen lib tests: expr::index_get_claim_tests::the_number_context_coercion_is_coupled_across_every_arm fails with left: 27, right: 24.

Root cause

It was a test merge collision, not a codegen defect. The coupled-coercion test asserted the dynamic obj[i] site's block count as a literal. #11588 (a growth-forwarding hop: fwd_check/fwd_follow/fwd_header) and #11589 (the byte-view arm: u8.brand/u8.bounds/u8.load) each bumped that literal from 21 to 24 on its own. Together the site has 27 blocks. The sibling test's full block list merged cleanly, but the count literal did not.

The codegen already satisfies the invariant. The byte-view arm's value is a uitofp byte, which is a Number by construction, the same as the tav.w* typed-array arms (these never coerce by design; see the lower_inline_dyn_typed_array_get doc). The forwarding hop produces no value and only re-enters arrlike.ic.brand. The number-context and plain IR shapes are identical.

Fix (test-only, and stricter)

  • One shared DYNAMIC_INDEX_SITE_BLOCKS list now pins the full ordered site shape. Both tests compare against it, so the coupled test checks the exact sequence instead of just a length. A future arm updates one list.
  • The coupled test now also covers the arms it didn't check before: arrlike.u8.load and tav.w8/w4/w2/w1 must never call js_number_coerce, and the u8 value must be a uitofp i8.

No emitted IR changes, so there is no perf impact on the #11588/#11589 wins.

Validation

  • Fails on pristine origin/main (efc0cb5): left: 27, right: 24. Passes with this change.
  • cargo test -p perry-codegen: 42 test binaries, 0 failures (lib: 1787 passed, 1 ignored).
  • cargo fmt --all -- --check OK. scripts/check_file_size.sh OK.

Not run: the gap suite, other crates' tests, and run_lint_gates.sh. This is a codegen test-only change.

Summary by CodeRabbit

  • Tests
    • Updated checks for dynamic indexed reads to verify the expected generated code paths, including that byte-view and typed-array loads avoid unnecessary number coercion.
    • Confirmed byte-view loads preserve the expected byte value behavior. These updates improve test accuracy; no end-user behavior changes are included.

…o count literals

#11588 (forwarding hop, +3 blocks) and #11589 (byte-view arm, +3 blocks)
each bumped the coupled-coercion test's hardcoded block count from 21 to
24; merged, the site has 27 blocks and the literal was stale. The codegen
is correct: the byte-view arm yields a uitofp byte (a Number by
construction, like the typed-array width arms) and the forwarding hop
yields no value.

Both tests now compare against one shared DYNAMIC_INDEX_SITE_BLOCKS list
(the full ordered shape, stronger than a length), and the coupled test
additionally asserts the u8 and tav.w* arms never coerce.
@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: d03e228e-9230-4371-b999-fabf066aac6c

📥 Commits

Reviewing files that changed from the base of the PR and between efc0cb5 and 8cec12d.

📒 Files selected for processing (2)
  • changelog.d/11603-codegen-number-context-coupled-arms.md
  • crates/perry-codegen/src/expr/index_get_claim_tests.rs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

Dynamic index read tests now use one shared ordered block-label list for site-shape checks. The number-context test also checks that byte-view and typed-array load arms do not coerce their results, and that byte-view loads use unsigned-byte conversion.

Changes

Dynamic Index Read Tests

Layer / File(s) Summary
Emitted shape and load conversions
crates/perry-codegen/src/expr/index_get_claim_tests.rs, changelog.d/11603-codegen-number-context-coupled-arms.md
Site-shape assertions use a shared ordered block-label list. Number-context assertions check that byte-view and typed-array load arms do not call js_number_coerce, and that byte-view loads use unsigned-byte conversion. The changelog records these test updates.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Merge Risk: ⚪ Minimal · up to 8cec1

This PR strengthens dynamic-index codegen regression tests without changing production code. The added checks cover the stated load arms, and no merge-blocking risk is evident.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. (1 skipped: 1 …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies a codegen test fix caused by the changes in #11588 and #11589. It is concise and specific.
Description check ✅ Passed The description explains the failure, root cause, test-only fix, stricter assertions, validation results, and tests that were not run. It provides the required information, although it does not use al…
✨ Finishing Touches 💡 1
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@proggeramlug
proggeramlug merged commit 3558c5a into main Sep 28, 2026
55 of 57 checks passed
@proggeramlug
proggeramlug deleted the fix/codegen-number-context-coupled-arms branch September 28, 2026 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant