Skip to content

test(typed-array): re-pin fractional-index expectation to spec-correct undefined (unblocks cargo-test on main) - #6961

Merged
proggeramlug merged 1 commit into
mainfrom
fix/ta-fractional-index-expectation
Jul 29, 2026
Merged

test(typed-array): re-pin fractional-index expectation to spec-correct undefined (unblocks cargo-test on main)#6961
proggeramlug merged 1 commit into
mainfrom
fix/ta-fractional-index-expectation

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

What

Fixes the inline_typed_array_fast_path_matches_slow_path failure that has held cargo-test red on main since the Jul 28 nightly (it replaced the proxy failure that #6907 cleared, and it currently blocks the v0.5.1265 release gate).

This is a stale test expectation, not a code regression — the runtime got more spec-correct and the test was pinned to the old bug.

Root cause

Section (B) asserted g(t, 1.5) === g(t, 1) for t = new Int32Array(3), i.e. that a fractional index truncates to 1. The test's own comment documented this as a deliberate encoding of a known-wrong behavior:

a pre-existing quirk: the untyped dynamic getter truncates a fractional index rather than returning undefined … since the whole point is that inline == slow.

Per §10.4.5.2, a non-integral canonical numeric index is not an own property of an integer-indexed exotic object, so [[Get]] yields undefined. #6903 (representation-selection Phase 1 — canonical unboxed i32 locals) made both the inline and slow paths spec-correct, so the comparison is now false and the pinned string no longer matches.

Attribution is solid from both directions: the Jul 27 nightly (b5727f305, pre-#6903) did not fail this test, the Jul 28 nightly (95960e0df, post-#6903) does, and building b0d789dab (#6903) directly reproduces the new B=true,true,false,true.

Why this is safe to re-pin rather than revert

The invariant the test exists to protect — inline path == slow path — still holds; only the shared value changed. Verified directly with a probe that exercises both paths on the same inputs:

inline t[1.5]=undefined  t[-0.5]=undefined  t[2.7]=undefined
slow   t2[1.5]=undefined t2[-0.5]=undefined t2[2.7]=undefined   # under PERRY_TA_VIEW_GUARD
slow view[0.5]=undefined

node --experimental-strip-types produces exactly the same three lines, and the same B=true,true,false,true for the test's own section (B). So the paths agree with each other and with node.

Changes

  • Correct the pinned expectation to B=true,true,false,true and rewrite the (B) comment to explain that the quirk was fixed by perf(codegen): representation-selection Phase 1 — canonical unboxed i32 locals #6903, citing §10.4.5.2, instead of documenting it as permanent.
  • Strengthen the test: add a B2 line asserting t[1.5]/t[-0.5]/t[2.7] are each === undefined. The old (B) form only asserted "not equal to t[1]", which a future regression returning some other wrong value (0, garbage, a truncated read of a different slot) would still satisfy. B2 pins the actual value, so this test now guards the corrected behavior rather than merely tolerating it.

Test-only change; no runtime or codegen code is touched.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed typed-array access with fractional or NaN-like indices so values such as 1.5 correctly return undefined instead of being treated as truncated integer indices.
    • Ensured consistent results across optimized and fallback execution paths, matching standard runtime behavior.
  • Tests

    • Added stronger regression coverage to verify correct results for multiple non-integer index values.

…t undefined

inline_typed_array_fast_path_matches_slow_path asserted g(t,1.5) === g(t,1)
— a deliberate encoding of the truncate-a-fractional-index quirk, as its own
comment documented. Per 10.4.5.2 a non-integral canonical numeric index is
not an own property, so [[Get]] yields undefined; #6903 (representation-
selection Phase 1) made both the inline and slow paths spec-correct, so the
pinned string stopped matching and cargo-test has been red on main since the
Jul 28 nightly.

The invariant the test protects (inline == slow) still holds — both paths
return undefined for 1.5 / -0.5 / 2.7, on an inline-eligible receiver and
under PERRY_TA_VIEW_GUARD, byte-identical to node. Correct the expectation,
rewrite the comment to cite the spec + the commit that fixed the quirk, and
add a B2 line asserting the values are === undefined: the old form only
asserted 'differs from t[1]', which a regression returning some other wrong
value would still pass.

Test-only; no runtime or codegen changes.
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 05ad220a-b714-47a4-9474-1739d1b7f621

📥 Commits

Reviewing files that changed from the base of the PR and between df68b83 and 9783c40.

📒 Files selected for processing (2)
  • changelog.d/6957-ta-fractional-index-expectation.md
  • crates/perry/tests/issue_5525_typed_array_untyped_index.rs

📝 Walkthrough

Walkthrough

The regression test now verifies that fractional and NaN-like typed-array indices return undefined on inline and slow paths, with updated expected output and changelog documentation.

Changes

Typed-array fractional indexing

Layer / File(s) Summary
Fractional index regression assertions
crates/perry/tests/issue_5525_typed_array_untyped_index.rs, changelog.d/6957-ta-fractional-index-expectation.md
The test explicitly checks undefined for fractional, negative fractional, and NaN-like indices on both paths, adds B2 coverage, updates expected stdout, and documents the corrected behavior.

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

Possibly related PRs

  • PerryTS/perry#6850: Changes typed-array reads to handle fractional indices without truncating to an in-bounds element.
  • PerryTS/perry#6883: Verifies undefined fallback behavior for fractional typed-array reads.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly names the typed-array fractional-index test expectation fix and matches the change set.
Description check ✅ Passed The description covers the fix, root cause, changes, and validation, though it doesn't use the template's exact section headings.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ta-fractional-index-expectation

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 1655c2f into main Jul 29, 2026
31 of 33 checks passed
@proggeramlug
proggeramlug deleted the fix/ta-fractional-index-expectation branch July 29, 2026 04:47
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