Repository navigation
-mm=own: an object literal capturing a let or a parameter borrows it (spec 69) - #740
Merged
Merged
Conversation
…r borrows it (spec 69)
`let d = ...; apply({ w: (x) => x + d.n }); d.n` was "captured by a closure that escapes", and
`return applyO({ w: (x) => x + item.n })` was "its value is the caller's".
- followClosure: a store into an unboxed record's field (spec 36) is no escape; the record's
reads, that field's reads and the calls given the record are the closure's uses.
- A literal's `.captured` box that classifyLiteralCaptures decides borrows is no generator
state's (classifyStateBoxes skips it). It borrows a cell of this frame's `let` too: rc's
RetainCell for it and the box's own go, and decideClosures checks that no use of the literal
comes after the cell is released or moved away.
- The spec 68 record path takes the same cells.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes the two
-mm=owngaps left after spec 68. Both are now spec 69.Changes
followClosure: a typed literal's arrow is a closure stored into an unboxed record (spec 36). That record owns nothing, so storing into its field no longer counts as an escape. The closure's uses are now:ts.ExtractProperty);.capturedboxes vs. generator state:classifyStateBoxestreated every literal's.capturedbox as a generator's state, which owns its cells and copies. A box thatclassifyLiteralCapturesdecides borrows (specs 67/68) is now skipped there. It borrows a cell of this frame'sletthe way a closure that does not escape does:RetainCellfor the cell is erased, and so is the box's own;decideClosuresreports an error if anything uses the literal after the cell is released or moved away.capturedBoxBorrows) accepts the same cells.Test
New test
own_literal_let_captures, run under own, rc, gc and none, with churn between steps. It captureslets in three ways and reassigns them afterwards:constliteral that is both called and passed on;It also captures parameters in literals given to object-type and interface parameters.
Results
🤖 Generated with Claude Code