-
Notifications
You must be signed in to change notification settings - Fork 16
Description
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.