Repository navigation
-mm=own: a callback field keeps its family when other classes extend the class - #709
Merged
Merged
Conversation
…the class A derived class reaches its base's field in the base's storage; that access now has the same family key, so the family stays closed while no class on the chain is built by another module or becomes an interface, any or a union (spec 57). 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.
Under
-mm=own, a callback stored into a class's field now keeps its family when other classes extend the class. Before, any derived class opened the field's family, sothis.f(a[i])in the base class's method reached any function. The new spec section is 57, and the limits in the user doc are updated.Changes
Same key through the base's storage. A derived class's object holds its base's storage as its first field. A derived class reaches the base's field there, through a
ts.PropertyRefof!ts.ref<!ts.class_storage<@Base>>, and the family used to see no such access. NowfieldFamilyKeygives that access the same key as one through an object of the base class: the class's constructor and-1 -the field's position. So a derived class's reads of the field (this.f(v)) and stores into it (this.f = drain) count toward the field's family.onlyCalledValuealso treats a store into such a field as passing the parameter on.When the family stays closed. Neither the class nor any class extending it may be built by another module, and no object of a class on that chain may become an interface,
any,object,unknownor a union. A cast from a derived class to its base (SubtoWalker) keeps the family closed. The base-class check already in the file moved into a static helper,extendsClass, that both places now use.Tests
own_callback_extended: a derived class, and one two levels down, store into and call the base's field, with churn between steps. It runs under own, rc, gc and none, and own emits no counting. A repro of the same shape failed on main.own_err_callback_extended_drops: a derived class stores a callback that replaces a global array, and the walk reads an element of it after the call. It errors at:16:13. With a harmless callback swapped in, the same file compiles.not ownare refused by design: untypedMaps, anArray<T>of objects, andreduceRightreturning an element.Not in this PR
A class whose object, or a derived class's object, becomes an interface or
anystill keeps its fields' families open.🤖 Generated with Claude Code