Repository navigation
-mm=own: objects in Map and Set go through Shared<T> - #697
Merged
Merged
Conversation
- @SharedElements on a generic class: under own each type argument has to be a value, a string or a Shared<T> handle. Checked where the class is specialized, at the user's `new` or annotation, before its members are generated; a plain object or `any` is an error that points at Shared<T>. A `new` whose inferred arguments were refused does not fall back to the defaults (which would report `any` again). - A tuple entry made of a handle beside borrowed strings retains the handle. - A yield that takes a handle out of a generator's state hands the state's count to the caller: the state's release of the old value is now erased for a handle as for any value. Walking a Map of two handles freed the first. - The owned result of a virtual call is decided over the methods on the receiver's class chain only, not every method of that name in the module: with the default library loaded, a Shared<T> returned through a vtable leaked under rc. Tests: own_shared_elements, own_shared_yield_count, own_err_shared_elements_object/_any/_inferred. Spec section 6 of 2026-10-26-own-generic-containers-design.md; docs limits updated. 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, an object goes into aMaporSetas aShared<T>handle. A plain object oranyelement is now a compile error at the user's code that points atShared<T>, where it used to be four errors insidelib.generics.ts. Spec: section 6 of2026-10-26-own-generic-containers-design.md.Changes
@sharedElements, a class decorator. Under own, each type argument of a class that carries it must be a value, a string, or aShared<T>handle.checkSharedElementsruns in bothinstantiateSpecializedClassTypeoverloads, with the location of the user'snewor annotation, before the class members are generated:newhas its inferred type arguments refused, it no longer falls back to the default type arguments, which would reportanya second time. The other memory models ignore the decorator. The compiler doesn't nameMaporSetanywhere; the DefaultLib PR adds the decorator to them.copyIntoTuple). When a tuple is made of a handle and borrowed strings, it now retains the handle, just as it copies the strings.Mapof two handles withfor…offreed the first one.OwnedReturnConsumptionPass). Whether the call returns +1 used to be decided over every method of that name in the module. With the default library loaded,A.getwas grouped withHeaders.getand similar methods, and aShared<T>returned through a vtable leaked under rc. Now it's decided over the receiver's class chain only (onReceiverChain).Tests
own_shared_elements: a local@sharedElementscontainer of numbers, strings and handles, under gc, rc, none and own.own_shared_yield_count, under rc and own: two entries walked, a yielded pair, and abreak; counts are checked after each. It fails without the yield fix.own_err_shared_elements_object,_any,_inferred.map_*/set_*under own: the same 16 pass as before. The 8 untypednew Map()tests now fail with the new error.map_sharedpasses under all four models, and under the JIT for own and rc.The DefaultLib PR depends on this one.
🤖 Generated with Claude Code