Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

A tricky case of isorecursive subtyping #272

Closed
@tlively

Description

@tlively

I've found what I believe to be a bug in Binaryen's implementation of the isorecursive type system described in #243, but it's a little tricky so I wanted to double check my understanding. Consider the following types (using made up subtype notation):

(type $A (struct))
(type $B (struct) sub $A)

(type $A' (struct))
(type $B' (struct) sub $A')

(type $X (struct (ref $A)))
(type $Y (struct (ref $B')) sub $X)

Here $A defines the same type as $A' and $B defines the same type as $B'. The subtyping $Y <: X is valid only if $B' <: $A, which should be true due to the type equivalences. The problem is that Binaryen checks for subtyping validity before canonicalizing the types, so it considers $A and $A' to be distinct types at that point and throws an error because it does not think that $B' <: $A is true.

Am I correct that this is a bug? Is the fix as simple as canonicalizing types before checking subtype validity?

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