Skip to content

Wasm GC: make the canonical recursive identity witness spec-correct #318

Description

@chrisbbreuer

CI root: https://github.com/zig-utils/zig-js/actions/runs/29693769324/job/88210905183
Parent: #267
Related: #298
Roadmap: #142, #268, #134

Root cause and implementation

The canonical recursive type identity test expected ref.cast between unrelated concrete struct types to be invalid. Under the pinned GC validation rule, ref.cast rt may consume any valid supertype of rt; the prior program was therefore valid and could trap dynamically. It did not isolate canonical identity.

Commit 62ead6c8 uses struct.get type 1, field 0 instead. The operation accepts the produced type-0 reference only when the separately declared recursive groups are canonically equivalent. The structurally distinct group fails at that exact instruction with type mismatch.

Acceptance

  • Replace the cast with a type-sensitive operation whose operand must match the indexed concrete struct type.
  • Keep equivalent separately declared recursive groups valid.
  • Keep structurally distinct groups invalid with the exact instruction offset and type mismatch diagnostic.
  • Pass the focused validation test: 3/3, zero leaks.
  • Leave runtime cast semantics unchanged.
  • Pass Linux normal/TSan replacement CI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions