Repository navigation
-mm=own phase 5b: a closure that escapes owns what it captures; a call in a try body is a call - #437
Merged
Merged
Conversation
Each cell moves into the box where the box takes it: rc's RetainCell goes, and so does every frame ReleaseCell the move reaches, which it must dominate. A use of the variable in the frame after the move, a second capture, a capture in a loop of a cell made outside it, a parameter's cell with a heap value and a cell inherited from an enclosing closure are errors. Copies move in as in phase 4. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Calls in a try body lower to ts.Invoke / ts.InvokeHybrid, which neither ownership pass recognised: such a call dropped no borrow (a field read across reset(h) in a try compiled and read freed memory), resolved to no callee, and returned nothing fresh. directCallee/calleeValue/callArgs now take every call form apart. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 5b of
-mm=own(spec §2.5; plandocs/superpowers/plans/2026-10-02-own-phase-5.mdtask 4; results in spec §17). It also fixes a soundness hole that predates phase 5.A call inside a try body was not a call (pre-existing, fixed)
Calls in a try body lower to
ts.Invoke/ts.InvokeHybrid, and neither own pass knew those ops. Three consequences:h.cheld acrosstry { reset(h) }, whereresetoverwritesh.c, compiled and printed 999 (gc: 1).directCallee/calleeValue/callArgsnow take every call form apart, andisCall/isFreshknow both ops. Regression test:own_err_call_in_try_drops. Because a call in atrynow returns a fresh value, fourusingfiles and51exceptionscompile under own now (all checked at runtime, below).Closures that escape
A closure over a variable that escapes (returned, stored, pushed, kept) owns what it captures. Its box keeps the owning routine, which destroys cells and copies.
ts.RetainCellgoes, and so do the frame'sts.ReleaseCells that store reaches; it must dominate them, or the error is moved here on some paths only.makeScaler(k)).The limit users will hit first: a closure that escapes cannot capture
thisor an object parameter. An event-handler styleregister(() => this.x)is rejected.Verification
test-compile-gc-defaultlib-collector, is the same as on -mm=own phase 5a: a closure that does not escape borrows what it captures #436: the installed default library atI:\tslangis stale. All 367owntests pass, including the new ones.owntests pass.13actions,51exceptions,00disposable,00try_catch_return_dispose,00using_nested_scopes,01try_catch_return_dispose) pass undertest-runner -mm=own, AOT and JIT, and their JIT output matches gc.measure.ps1onown_closure_escapegives gc 5.9, rc 4.3, none 234.6, own 4.3 MB.ReleaseCells kept after a move,own_closure_escapecrashes under AOT (0xC0000005).Tests
own_closure_escape(object local, number parameter, counter, copy beside a cell, called before being returned, kept by a constructor, pushed into a global).own_err_closure_escape_used,_twice,_param,_loop,_inherited,_some_paths, andown_err_call_in_try_drops.own_err_closure(an escaping counter) compiles now and is removed.Found, not fixed (every model)
MLIRGen segfaults on pushing a closure that returns
s32into a(() => number)[], e.g.let h: (() => number)[] = []; function r() { let n = 0; h.push(() => n); }. Since0iss32, that is the natural way to write it. It is unrelated to own; I can file an issue.🤖 Generated with Claude Code