Skip to content

fix(types): derive structural clone and equality from members - #2907

Open
slepp wants to merge 5 commits into
mainfrom
feat/structural-clone-and-equality
Open

fix(types): derive structural clone and equality from members#2907
slepp wants to merge 5 commits into
mainfrom
feat/structural-clone-and-equality

Conversation

@slepp

@slepp slepp commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Two operations a user reaches for immediately did not work.

Option<i64> had no clone. Two (i64, string) tuples could not be compared — the attempt failed with IntCmp aggregate operands must be named structural-equality types and emitted under-release warnings alongside it.

Both now follow one rule: an aggregate has a capability when every member has it, and is refused with a diagnostic naming the offending member otherwise. Refusals identify the member by path, such as item.Some.1. Tuples, Option, Result and records compose, including through nesting.

The two share that rule but not their lowering — equality goes through comparison thunks, clone through snapshot plans that carry drop obligations.

Ownership

An affine or resource-bearing value never gains Clone. Manufacturing one would produce two owners of a single resource, which is the double free the release exists to prevent. Cloned aggregates own their contents independently.

The under-release warnings on the comparison path were not noise. IntCmp aggregate reads were being treated as ownership escapes, which removed the normal drop plans for the compared values. A comparison borrows its operands, and is now modelled that way.

Verification

Accepted and refused shapes are pinned as fixtures. Leak oracles pass in both directions, so a cloned aggregate is released exactly once per owner and a refused clone never partially copies. The compiled Hew suite, core matrix, vertical slice and compiler tests all pass.

slepp added 3 commits August 11, 2026 23:32
I inspect non-cloneable generic handle payloads before classifying the outer handle as opaque, so collection clones reject nested resources at the checker boundary.
@slepp
slepp force-pushed the feat/structural-clone-and-equality branch from 29cc3d1 to 5841b81 Compare August 12, 2026 05:40
@slepp

slepp commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

The actual first failure is infrastructure, not the structural clone/equality tests: wasm-pack failed while downloading Binaryen 117. Current main contains 08b49afc8, which prefetches Binaryen with retries. This needs a refresh onto current main and a clean CI rerun before review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant