Repository navigation
-mm=own: a field taken out of the object an owning let holds (spec 65) - #730
Merged
Merged
Conversation
`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>
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.
Summary
-mm=own spec 65: spec 64's field take for an owning
let.let r = new Holder(); return r.value,c ? initial : r.valueandinitial ?? r.valueused to fail with "'this value' borrows a field and cannot be stored, returned or captured".A
letis a slot (an owningts.Variable), not a folded name, sonamedFieldTakeOfnow also accepts a read of a field of a load of an owning, uncaptured local: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;new's or a call's own result. Without this,let r = g; return r.valueemptied the global's field, because a global is immortal under own and a local given one counts as owning. Spec 64'sconstpath now uses the same check.rc's
consumeConditionalResultsretains 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_takeunder 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, aletdeclared 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).🤖 Generated with Claude Code