Skip to content

Re-wrapping with mismatched signatures #53

@jakobkummerow

Description

@jakobkummerow

I would appreciate some more clarity (and perhaps also discussion...) on the expected behavior when using new WebAssembly.Function(inner_func, $sig0) for the case where inner_func has a signature (because it's another WebAssembly.Function, or an actual exported Wasm function) that doesn't match $sig0.

I understand that there is some limited coverage of this scenario in the existing tests, from which it can be inferred that currently the intention is that this should throw an error at runtime. If that is indeed intended, I would appreciate it if it was called out explicitly somewhere. If my understanding is wrong, then I would appreciate some clarification even more.

I also have some doubts whether that intention makes sense -- wouldn't it make more sense to make the WebAssembly.Function constructor itself throw immediately when someone attempts to construct something that can't possibly work at runtime? In other words, wouldn't it make sense if new WebAssembly.Function(inner_func, $sig0) took some inspiration from what happens when you do new WebAssembly.Instance(... { import_with_$sig0: inner_func } ...)?

Perhaps re-wrapping could even be disallowed entirely, on the grounds of being useless?

As a pragmatic observation, the current state of things has a tendency to cause confusion in humans and bugs in implementations -- with the latter being time-consuming to resolve due to the former.

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