Repository navigation
-mm=own: a class family spans one class hierarchy, not every class with that slot - #717
Merged
Merged
Conversation
…th that slot
A virtual call's family was every function at its vtable position under its
method name, in any class. Two specializations of one generic class -
Array<string> and Array<int> - were one family, though neither extends the
other: `find` returns a borrow for one and a number for the other, the family
disagreed, both lost their facts, and any program with both failed under own
("'this value' borrows a field and cannot be stored, returned or captured").
Families are now keyed by the root of the class's chain of bases as well
(familyRoot, through the class storages, now collected before the vtables). A
slot with a member whose root is not known stays one family, as before.
Test: own_generic_specializations (Box<string> and Box<int>).
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.
-mm=own: a class family spans one class hierarchy
Under
-mm=own, any program that made both anArray<string>and anArray<int>(orArray<number>) failed to compile, with errors inside DefaultLib'sArray<T>:OwnershipSignaturePassgives a virtual call the facts every member of its family agrees on. Afamily was every function at that vtable position under that method name, in any class
(
collectClassVTables). Two specializations of one generic share every slot and name, soArray<string>.find(returns a borrow) andArray<int>.find(returns a number) were onefamily, disagreed, and both lost their facts - though neither class extends the other and no
call through one can reach the other.
Families are now keyed by the root of the class's chain of bases as well (
familyRoot: a baseis the first field of a class's storage, as
extendsClassreads it).familyOflooks a call upby its callee's class's root. A slot one of whose members has a root not known here (storage not
seen, or a chain deeper than 64) stays a single family, as every slot was before. The class
storages are now collected before the vtables.
Overrides within one hierarchy are unchanged:
own_err_borrowed_result_family(an override thatreturns a new object where its base returns a field) still errors.
Tests
own/own_generic_specializations.ts:Box<string>.findandBox<int>.findreturning ahelper's result. Fails under own without the fix (string-only passes); runs under own, rc, gc
and none, plus own's no-counting check.
tests.ps1: gc, rc, none, own all pass in all four passes.new Array<string>("a", "b")next to
new Array<number>(10)compiles and runs under own.🤖 Generated with Claude Code