Skip to content

test(ts): replace through a pointer with the old value unread - #380

Merged
moq-bot[bot] merged 1 commit into
mainfrom
resolve-ts-ptr-replace
Nov 1, 2026
Merged

moq-bot[bot] merged 1 commit into
mainfrom
resolve-ts-ptr-replace

Conversation

@kixelated

Copy link
Copy Markdown
Collaborator

Problem

Quest m3/ts-ptr-replace-unread said ptr::replace with an unread result, such as let _ = p.replace(1), leaves const old unread and tsc refuses it (TS6133). That doesn't reproduce. No PR fixed it: the output was the same at #339, the PR that filed the quest. The mapping in ts/src/lower/pointer.rs hasn't changed since then.

An unread call result is lowered to a bare statement naming the old value (old;). tsc counts that as a read, even under the fixture's noUnusedLocals. The tsc gate from #376 also leaves unused names out, so it could not have caught this either way. I tried a named unused binding, let _, a bare statement, and a call in a branch, through pointers to a number, a u8, and an object. All type-check, both at main and at #339's merge.

Approach

Delete the quest and add the missing coverage: pointers::places now replaces through a pointer to a number, to a struct, and to a [u8; 2] with the result unread. Those are the three pointee kinds (Place, Object, Bytes). The lang fixture type-checks them with noUnusedLocals and runs them differentially against native wasm32. No existing case discarded a ptr::replace result.

Impact

  • No public API change.

Alternatives

  • Skip reading the old value when the result is unread, as mem::replace and Option::take do. The bare old; statement is dead code, but it's valid and has the correct semantics. Dropping it would be an output-size tweak with no current consumer, so I left it out.
  • Delete the quest without the fixture cases. I kept them because they're the only cases where a ptr::replace result goes unread.

Follow-ups

None.

Review

  • Reviewer: codex gpt-6.1-sol, medium effort, via quest review round 1.
  • Head: 6eb5022.
  • Findings: none.

🤖 Generated with Claude Code

The quest's TS6133 doesn't reproduce: an unread result of ptr::replace
lowers to a bare statement naming the old value, which tsc counts as a
read, as it did when the quest was filed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@moq-bot
moq-bot Bot merged commit ca98ff7 into main Nov 1, 2026
@moq-bot
moq-bot Bot deleted the resolve-ts-ptr-replace branch November 1, 2026 09:16
@coderabbitai

coderabbitai Bot commented Nov 1, 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 42 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: 7759e3b4-091b-415c-9ac8-8bf37bcdf8b9
Commits

Reviewing files that changed from the base of the PR and between 826d56d and 6eb5022.

Files selected for processing: 4
  • quest/m3/README.md
  • quest/m3/ts-ptr-replace-unread.md
  • ts/fixtures/lang/expected/pointers.ts
  • ts/fixtures/lang/src/pointers.rs
  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant