Skip to content

Conversation

Liedtke
Copy link
Contributor

@Liedtke Liedtke commented Sep 23, 2025

Any invalid / unsupported string should run into this, so this shouldn't be an assertion but an error?
I assume we don't need new tests as this should already be covered by https://github.com/WebAssembly/spec/blob/main/test/js-api/global/constructor.any.js#L82?

@tlively tlively requested a review from Ms2ger October 15, 2025 18:40
@Ms2ger
Copy link
Collaborator

Ms2ger commented Oct 16, 2025

Can you explain in which cases you think this can be reached? Note that the WebIDL layer ensures that a value of type ValueType is always one of the strings in the enum.

@Liedtke
Copy link
Contributor Author

Liedtke commented Oct 20, 2025

Note that the WebIDL layer ensures that a value of type ValueType is always one of the strings in the enum.

Thanks for pointing that out, I wasn't aware of that.
https://wasm-dsl.github.io/spectec/js-api/#idl-index defines the ValueType enum which the WebAssembly.Global uses.
Do I understand correctly, that any invalid value not specified by the IDL is always reported as a TypeError and that is defined once for WebIDL and then implicitly relied on by the wasm-js spec?

@Ms2ger
Copy link
Collaborator

Ms2ger commented Oct 20, 2025

Indeed, when converting a javascript value to an enumeration type (https://webidl.spec.whatwg.org/#js-enumeration), any invalid values will cause an exception.

(Btw, you can use https://webassembly.github.io/spec/js-api again.)

@Liedtke
Copy link
Contributor Author

Liedtke commented Oct 20, 2025

Indeed, when converting a javascript value to an enumeration type (https://webidl.spec.whatwg.org/#js-enumeration), any invalid values will cause an exception.

Closing this PR as I was just missing context about how to read the spec, thank you for helping out!

(Btw, you can use https://webassembly.github.io/spec/js-api again.)

I updated my bookmark, thanks for the hint. :)

@Liedtke Liedtke closed this Oct 20, 2025
@Liedtke Liedtke deleted the fix_tovaluetype_error_case branch October 20, 2025 11:23
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.

2 participants