Repository navigation
-mm=own: let [a, b] = pair borrows each element, as let a = pair[0] does - #677
Merged
Merged
Conversation
…]` does
A destructuring declaration reads each element behind a test of the array's
length whose other side is the default, so the local's value arrived through a
merge, and own refused it ("merged from several branches") though the plain
read `let a = pair[0]` is an element borrow. placeReadOf now sees through a
merge whose every other way in passes a default or what holds no block
(soleBlockMergedInto): the local is that element read, and checkPlaceRead's
walk from the read already follows the branch to it, so reassigning or
shrinking the array, storing, returning or capturing the local is still an
error. A string element is copied, as any string read out of an element is.
Own corpus 533 -> 534 (00owned_locals), none lost. Tests: own_destructure_elements
under every model, 00owned_locals under own, two negatives with pinned messages.
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.
What
Under
-mm=own,let [a, b] = pairnow borrows each element, aslet a = pair[0]already does. String elements are copied, as any string read out of an element is (spec 22).Why
A destructuring declaration reads each element behind a test of the array's length whose other branch yields the default. The local's value therefore arrives through a merge (a block argument), and own refused it: "is merged from several branches". This cost the corpus file
00owned_locals(follow-up 14 from own-raytrace).soleBlockMergedInto(OwnershipFacts.h) finds the one value a merge can bring a block in by, when every other way in passests.Default/ts.Null/ts.Undefor something that holds no block.placeReadOfuses it, so the local becomes that element read.checkPlaceRead's walk from the read already follows the branch to the local, so the borrow's end is still checked.These are still errors (probed, and two of them pinned): reassigning the array, storing into an element,
shift, returning the local, storing it into a field, and capturing it.Tests
own_destructure_elementscovers class elements, built strings that outlive their array, and destructuring in a loop. It runs under own (including the no-counting check) and under rc, gc and none.00owned_localsnow runs under own.own_err_destructure_element_reassignedandown_err_destructure_element_returned.MALLOC_PERTURB_.🤖 Generated with Claude Code