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.

Anyref vs. Externref in JS-API #108

@eqrion

Description

@eqrion

On the web, externref can hold any JS value and funcref can hold exported wasm functions. In this proposal, anyref is added as the super type of externref and funcref.

Is there any difference between anyref and externref when used in a param of an exported wasm called by JS? Or generally in ToWebAssemblyValue [1]. It seems like if externref can accept any JS value, then anyref must as well as the super type of externref.

One oddity of this is that funcref and externref have overlapping sets of values. externref is any JS value and funcref is any exported wasm function (which is a JS value). So the subtypes of anyref aren't disjoint over the values they accept.

I haven't been able to write any code that would break with either of these facts, but I just want to make sure this is intentional and how I should read the proposal.

[1] https://webassembly.github.io/reference-types/js-api/index.html#towebassemblyvalue

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