Skip to content

-mm=own: a move in a scope released on the unwind leg empties the moved-from slot - #771

Merged
ASDAlexander77 merged 1 commit into
mainfrom
own-await-typed-catch-itanium
Nov 5, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
own-await-typed-catch-itanium

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Why

The v0.0-pre-alpha114 release (run 42096924048) failed DefaultLib's promise.ts under -mm=own on every ubuntu runner:

promise.ts:15:11: error: 'this value' is moved here on some paths only; -mm=own cannot release it on the others yet
    const awaited = await Promise.all([twice(3), twice(4)]);
promise.ts:8:17: note: released here on every path

Not a regression and not await-specific. Under own, a local moved to another one (const b = a, or the value moved out of an await's slot) in the body of a TryOp is rejected: the scope's release in the cleanup landing pad is reached from before the move and after it, and spec 30's edge releases can't go on an unwind edge. On Itanium every function body that holds a typed catch is wrapped in such a TryOp, so on Linux any move at the top level of such a function fails. An explicit try { const b = a; ... } failed on Windows too.

Fix

A hoisted owned local's slot starts null (VariableOpLowering) and a release of null does nothing. So when the only release a move can't settle is in an exception handler, the move now stores an empty value (ts.Default) into the moved-from slot right after it and leaves the handler's release in place. That release then frees the value only on paths that unwind before the move. Applied only when the read, the taker and rc's retain are in one non-handler block with no call between them, and the taker isn't a call (a call may throw having taken the value or not). Everything else still gets the existing diagnostic.

Tests

  • 00own_move_in_unwound_scope.ts: a move in a try with throws before and after it, a move beside a typed catch, an await beside a catch, the await Promise.all([...]) shape, and a throw out of the function after the move. Each runs 1000 times. Registered for compile and JIT, default model and own, and in the rc/none corpus.
  • test-compile-own-move-in-unwound-scope-{x86_64-pc-windows-msvc,x86_64-unknown-linux-gnu}: --emit=llvm for both triples on any host, so Windows CI also covers the Itanium wrapping.
  • Before the fix the test fails on both triples; after it, all 10 entries pass. The full Windows release suite passes (6651/6651). The Linux runtime run is this PR's Linux CI.
  • The old DefaultLib promise.ts (PR more no default opts finished #65 version) now compiles under own for both triples.

🤖 Generated with Claude Code

…ed-from slot

Under own, `const b = a` (or a value moved out of an await's slot) in the body of a TryOp was
"moved here on some paths only": the scope's release in the cleanup landing pad is reached from
before the move and after it, and no release can go on an unwind edge (spec 30's edge releases need
a branch). On Itanium every function body with a typed `catch` is wrapped in such a TryOp, so on
Linux this hit any move at the top level of such a function - DefaultLib's promise.ts
(`const awaited = await Promise.all([...])` beside a `try/catch`) failed the v0.0-pre-alpha114
release under own on every ubuntu runner. An explicit `try` body failed on Windows too.

The slot of a hoisted owned local starts null (VariableOpLowering) and a release of null does
nothing, so the move now stores an empty value into the slot right after it, and the handler's
release stays: it frees the value only on the paths that unwind before the move. Only when the read,
the taker and rc's retain are in one non-handler block with no call between them, and the taker is
not a call (one that may throw having taken the value or not).

Test: 00own_move_in_unwound_scope.ts, run under every model, plus an --emit=llvm check for the
Windows and Linux triples on any host.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit d876225 into main Nov 5, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the own-await-typed-catch-itanium branch November 5, 2026 22:13
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