Skip to content

-mm=own: a tuple of owned values, and a record a call returns, are values - #679

Merged
ASDAlexander77 merged 1 commit into
mainfrom
own-tuple-of-owned
Oct 23, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
own-tuple-of-owned

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

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.

Shape Before Now
[mk(1), mk(2)] as [N, N], built in a local or returned refused: "takes a second reference" own builds it in a slot, as an object literal is built (createTupleInSlot), and reads that as the literal taking each value
const r = rec(); r.a.x + r.b.x refused: the first ts.ExtractProperty moved the record, so the second read was "used here after its value was moved" a field that is only read counts as a read of the record (fieldOnlyRead), and so does each read of that field, so a use after the record is moved is still caught
let [a, b] = pair() refused each let borrows its field until the record is released, the same way a let already borrows a temporary (fieldTakersOf in checkValueMoves); decideRetains skips the retains that borrow already erased

A tuple of literals or of existing reads ([1, "a"], [[1, "x"], 2], [items[1]]) is still one ts.CreateTuple. The check uses own_facts::isConstantData and looks through casts and views. Other memory models are unchanged.

Still refused

Each is pinned by a new negative test:

  • returning a record's field (own_err_record_field_returned);
  • returning a destructured local (own_err_destructured_field_returned);
  • reading a field after the record went to a callee that keeps it (own_err_record_field_after_move);
  • reading a field of a spec-32 borrowing record after its argument is overwritten (own_err_borrowing_record_const_field).

Tests

  • own_tuple_record_values runs under own (including the no-counting check) and under rc, gc and none.
  • Own corpus on Linux: 535 → 537 files accepted (00tuple_runtime_arrays, arrayLiterals3), both giving the same output as gc under MALLOC_PERTURB_. None lost.
  • Full suite: Windows 5509/5509, Linux 5488/5488.

🤖 Generated with Claude Code

…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>
@ASDAlexander77
ASDAlexander77 merged commit 0694046 into main Oct 23, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the own-tuple-of-owned branch October 23, 2026 22:02
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