Skip to content

fix(ts): keep a Vec's room in a raw slice cast to an array - #632

Merged
kixelated merged 1 commit into
mainfrom
fix/raw-slice-array-room
Nov 7, 2026
Merged

kixelated merged 1 commit into
mainfrom
fix/raw-slice-array-room

Conversation

@kixelated

@kixelated kixelated commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

RawSlice.array(n), the runtime half of a *const [T] cast to *const [T; N] from moq-dev/rust2#624, viewed the Vec's items alone. A raw slice into a Vec's spare capacity, as v.as_mut_ptr().add(v.len()) makes since moq-dev/rust2#623, lost the Room holding those slots, so a read through the array gave undefined (TypeError: Cannot read properties of undefined). CodeRabbit flagged it on #624's queued head (review).

Fix

array(n) builds its slice over sliceArray(at, n), the room-aware view ptrSlice already uses, without ptrSlice's reach check, so the cast still checks nothing, as in Rust.

lang/elements' spare::pointers now casts the room's raw slice to *mut [T; 2], swaps, and reads through it, for u32, String, and Option<u16>. Without the fix, 31 of 1345 differential cases differ from native wasm32.

Impact

Translator output unchanged. Runtime: RawSlice.array of a slice into a Vec's room reads and writes the room.

Caused by

Validation

  • just ts test --test fixtures lang::elements: passes; fails with 31 differences on the runtime without the fix
  • just ci: everything passes except lang/dyns (ids.ts) and lang/panics/hook (lib.ts), whose TypeId hash snapshots differ. That reproduces unchanged on origin/main (33fa28d4/d0c268d5) in this checkout, while the merge queue's build of d0c268d5 passed, so the hashes look environment-dependent.

Follow-ups

  • TypeId snapshots from moq-dev/rust2#605 that differ by checkout: plan it, since every local just ci outside CI fails until they're stable.

Models

Size: XS
Implementer: Claude Code, Claude Opus 5.5, high effort

(Written by Claude Opus 5.5 with high effort)

🤖 Generated with Claude Code

Review

Rewritten by quest review after each round.

  • Reviewer: Codex, gpt-6.1-sol, low effort
  • Session: 01a1b4c7-86ba-71d0-b1b9-d584e7fdf509, round 1
  • Head: 97c4b0a
  • Base: origin/main at d0c268d
  • Score: 10/10, The change reuses the existing storage adapter correctly and adds differential fixture coverage for reads and writes through raw-slice array views; no actionable defects were found, though tests were not run in the read-only environment.
  • Findings: none

RawSlice.array viewed the items alone, so a cast of a raw slice into a
Vec's spare capacity read undefined past its length.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pullfrog

pullfrog Bot commented Nov 7, 2026

Copy link
Copy Markdown

Pullfrog  | Review this ➔

@kixelated
kixelated marked this pull request as ready for review November 7, 2026 06:53
@coderabbitai

coderabbitai Bot commented Nov 7, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 11 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ecaac966-9709-4c85-b220-beb6ecb6b619
Commits

Reviewing files that changed from the base of the PR and between d0c268d and 97c4b0a.

Files selected for processing: 3

  • ts/fixtures/lang/elements/expected/spare.ts
  • ts/fixtures/lang/elements/src/spare.rs
  • ts/runtime/rs.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@kixelated kixelated left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review by review (OpenAI)

Reviewed head 97c4b0a against base d0c268d.

No actionable findings. RawSlice.array now uses the same room-aware storage selection as ptrSlice while retaining the original offset and requested array length. It does not introduce ptrSlice's reach check, and the existing no-memory-pointer guard remains before projection. RoomView reads and writes the spare slots through the original Room, so the new swap/read fixture observes those writes when the Vec subsequently takes the slots into its length. The generated cases exercise u32, String and Option.

Direction: retain this cross-feature regression coverage for raw-array casts into spare capacity. The separately reported environment-dependent TypeId snapshot failures are not resolved or validated by this change.

Verification limits: GitHub-only static review of the full diff and the surrounding RawSlice, sliceArray, Room/RoomView and Vec storage helpers. No compilation, differential tests, mutation checks or CI were run, and the author's reported pass/failure counts were not independently reproduced. This COMMENT is not a passing-build or merge-readiness claim.

(Written by review (OpenAI))

@kixelated
kixelated added this pull request to the merge queue Nov 7, 2026
Merged via the queue into main with commit efa6300 Nov 7, 2026
7 checks passed
@kixelated
kixelated deleted the fix/raw-slice-array-room branch November 7, 2026 07:06
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