Skip to content

-mm=own: a field taken out of the object an owning let holds (spec 65) - #730

Merged
ASDAlexander77 merged 1 commit into
mainfrom
own-let-field-take
Oct 29, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
own-let-field-take

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Summary

-mm=own spec 65: spec 64's field take for an owning let. let r = new Holder(); return r.value, c ? initial : r.value and initial ?? r.value used to fail with "'this value' borrows a field and cannot be stored, returned or captured".

A let is a slot (an owning ts.Variable), not a folded name, so namedFieldTakeOf now also accepts a read of a field of a load of an owning, uncaptured local:

  • the object is every read of the local. Its ends are the local's ReleaseSlots and the stores into it (after a store, reads see another object); the declaration and those stores make it anew, which is what the loop check tests;
  • spec 64's rules hold over every read: nothing but those ends sees the object after the move, nothing made of it before is used after (the walk now also follows a value stored into another local), and the read does not repeat without the local being made anew. Any other use of the slot refuses;
  • made here: the initializer and every store must be new's or a call's own result. Without this, let r = g; return r.value emptied the global's field, because a global is immortal under own and a local given one counts as owning. Spec 64's const path now uses the same check.

rc's consumeConditionalResults retains a branch that yields a field read out of an owning local, as it does for a named object, when a receiver keeps the merge.

Tests

  • own_let_field_take under own/rc/gc/none, churning: return, ?:, ?? from a call result, the read used before returning plus another field read after, the local given a new object after the take, a let declared in a loop, and one given anew in the loop. The verifier is silent and the own build has no counting.
  • own_err_let_field_{global,read_again,loop,captured}; also checked by hand: a parameter, a parameter assigned later, c ? p : new, a global assigned later, const r = g, let h = r, and a read on some paths (all rejected).
  • Windows: ctest 6261/6261; DefaultLib gc 178, rc/none 177 (+1 skipped), own 167 (+11 skipped)

🤖 Generated with Claude Code

`let r = new Holder(); return r.value` (and `?:`, `??`) was still "'this value' borrows a field and
cannot be stored, returned or captured". namedFieldTakeOf now takes a read of a field of a load of an
owning, uncaptured local: the object is every read of the local, its ends the local's releases and the
stores into it, and the declaration and those stores make it anew. Every value the local is given must
be `new`'s or a call's own result: a global is immortal under own, so a local given one is owning all
the same, and `let r = g; return r.value` emptied the global's field. The same rule now guards
spec 64's `const`. The derived-use walk follows a value stored into a local.

consumeConditionalResults retains a branch yielding a field read out of an owning local's load, as for
a named object.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit 65d30d7 into main Oct 29, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the own-let-field-take branch October 29, 2026 09:35
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