Repository navigation
-mm=own: a tuple of owned values, and a record a call returns, are values - #679
Merged
Merged
Conversation
…lues Three refusals of one shape, a tuple or record of owned values as a value: - `[mk(1), mk(2)]` as `[N, N]`, built in a local or returned: `ts.CreateTuple` took each value beside the temporary's own release, a second reference own could not place. Under own a tuple literal holding a value the expression made is built in a slot, as an object literal is (createTupleInSlot), which own reads as the literal taking it. A tuple of literals or of reads (`[items[1]]`, own_facts::isConstantData) stays one `ts.CreateTuple`. - `const r = rec(); r.a.x + r.b.x`: a field taken out of the record value (`ts.ExtractProperty`) moved it, so the second read was a use after the move. A field only read is a read of the record (fieldOnlyRead), and so is each read of it, so a use after a move of the record is still one. - `let [a, b] = pair()`: each `let` takes a field out of the returned record. It borrows the field, bounded by the record's release, as a `let` borrows a temporary (fieldTakersOf in checkValueMoves); decideRetains skips the `let`s' retains that borrow already erased. Still errors (pinned): returning a field or a destructured borrow, a field read after the record moved into a callee that keeps it, and a spec-32 borrowing record's field read after its argument is overwritten. Own corpus 535 -> 537 (00tuple_runtime_arrays, arrayLiterals3; same output as gc), none lost. Tests: own_tuple_record_values under every model and own's no-counting check, four negatives. 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, a tuple or record that holds owned objects can now be used as a value. This removes three refusals of that one shape.[mk(1), mk(2)]as[N, N], built in a local or returnedcreateTupleInSlot), and reads that as the literal taking each valueconst r = rec(); r.a.x + r.b.xts.ExtractPropertymoved the record, so the second read was "used here after its value was moved"fieldOnlyRead), and so does each read of that field, so a use after the record is moved is still caughtlet [a, b] = pair()letborrows its field until the record is released, the same way aletalready borrows a temporary (fieldTakersOfincheckValueMoves);decideRetainsskips the retains that borrow already erasedA tuple of literals or of existing reads (
[1, "a"],[[1, "x"], 2],[items[1]]) is still onets.CreateTuple. The check usesown_facts::isConstantDataand looks through casts and views. Other memory models are unchanged.Still refused
Each is pinned by a new negative test:
own_err_record_field_returned);own_err_destructured_field_returned);own_err_record_field_after_move);own_err_borrowing_record_const_field).Tests
own_tuple_record_valuesruns under own (including the no-counting check) and under rc, gc and none.00tuple_runtime_arrays,arrayLiterals3), both giving the same output as gc underMALLOC_PERTURB_. None lost.🤖 Generated with Claude Code