Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[js-api] Throw consistent exns in "read the imports" #523

Merged
merged 4 commits into from
Feb 16, 2024

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
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[js-api] Throw LinkError consistently
2 participants