Repository navigation
-mm=own: an interface seen as another interface, or inside a union, is the block it shows - #671
Merged
Merged
Conversation
…s the block it shows own_facts::isView took a cast between class, union and optional types as the same block, but not one from or to an interface. So `const b: B = a` (A to B), `const d: HasDist = mkHit()`, `return h` into `Hit | null`, and even a cast to a base interface (B extends A, A of B) were each a second reference own could not prove a move or a borrow of. Every interface-to-interface cast (#666, #669, #670) was rejected under own. The cast keeps `this`; the vtable laid out for the other interface is interned, nobody's block. So it is a view like the others, and own moves and borrows through it as it does the object: a read after `[a]` moved it is still an error. 00interface_cast_unrelated, 00interface_union_cast_unrelated, 00nullable_interface_to_interface and 00null_interface_to_interface now run under own too. 00interface_cast_unrelated's element and loop cases no longer move or merge `h` (own's rules, not this cast's). 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.
Fixes the own limitation that #666, #669 and #670 each listed under "Not covered":
-mm=ownrejected every cast of an interface value to another interface type with "'this value' takes a second reference; -mm=own cannot prove a move or a borrow here yet". It wasn't only the casts #666 remaps. Even a cast to a base interface was rejected, and so was an interface given to its own| null:Cause
own_facts::isViewdecides which casts are the same block as their operand. It took a cast between class, union and optional types, but not one from or to an interface. Ants.NewInterface(a class seen through an interface) was already a view.Fix
InterfaceTypejoins that list (OwnershipFacts.h). The cast keepsthis, and #666 interns the vtable laid out for the other interface, so no one owns it. own now moves and borrows through the cast as it does through the object. Only the own passes useisView; rc's and the lowering's are separate.Tests
The following now also run under own, as JIT and compile tests:
00interface_cast_unrelated;00interface_union_cast_unrelated;00nullable_interface_to_interface;00null_interface_to_interface.Two cases in
00interface_cast_unrelatedchanged to fit own's existing rules, not this cast's:[mkHit()]instead of[h], which movedh;cond ? h : hc. own rejects a ternary of two outer locals inside a loop for a plain class too.Tooth: on main, all four fail under own with "takes a second reference".
Probes (not in the suite):
aafter[a]moved it, throughconst b: B = a, is still "used here after its value was moved".Not covered
00interface_type_tag_in_vtablestays rc/gc/none. It pushes a borrowed array element into another array, which own rejects by design.Verification
MALLOC_PERTURB_=165 MALLOC_CHECK_=3.🤖 Generated with Claude Code