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

Conversation

takikawa
Copy link
Contributor

@takikawa takikawa commented Feb 15, 2024

Fixes #521. Goes along with #498.

Instead of allowing ToWebAssemblyValue to throw a TypeError, explicitly catch
any exceptions and throw a WebAssembly.LinkError.
Instead of allowing ToWebAssemblyValue to throw a TypeError, explicitly catch
any exceptions and throw a WebAssembly.LinkError.
@@ -370,7 +370,7 @@ A {{Module}} object represents a single WebAssembly module. Each {{Module}} obje
1. Throw a {{LinkError}} exception.
1. If |valtype| is [=v128=],
1. Throw a {{LinkError}} exception.
1. Let |value| be [=ToWebAssemblyValue=](|v|, |valtype|).
1. Let |value| be [=ToWebAssemblyValue=](|v|, |valtype|). If this operation throws an exception, catch it, and throw a {{LinkError}} exception.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should be specific to TypeError here. If there is any chance that TWAV could throw another exception (now or in the future), should that also become a LinkError? (Probably not.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it could make sense to be specific to TypeError, so I pushed that change. I think in practice it shouldn't be possible for TWAV to throw other exceptions at this particular call site currently.

For example, TWAV can throw a SyntaxError if BigInt conversion fails on a string but it should be guarded by the conditions here. But that property isn't immediately apparent either.

@rossberg rossberg merged commit 6f8e7bc into WebAssembly:main Feb 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[js-api] Throw LinkError consistently
2 participants