-
Notifications
You must be signed in to change notification settings - Fork 458
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
[jsapi] Should MemoryDescriptor["initial"] be required? #838
Comments
Yes, I think initial should be required. So I suppose it makes sense to remove the |
To be clear here, I believe this was optional in the previous informal spec, and marked as required because bikeshed's WebIDL linter was complaining. I don't know if it is web-compatible to be required. |
SpiderMonkey throws, V8 and JSC don't. The linter was likely complaining about the lack of |
I see. If that's the current web reality, maybe we should add the optional and make this not required, then. |
From my reading of the SM code, we don't throw when we see the property is missing, but rather due to the [EnforceRange] attribute which fails because |
Oh, and to finish that thought: as long as we still have [EnforceRange], I think we should make the attribute required. |
Note that the same applies to |
Ah, interesting. If a property is marked as |
Yes, exactly. |
Great, so then to summarize it seems like |
|
Because while it's common to create a memory without a maximum, creating a memory without an initial size is almost certainly an error. IMO the descriptor argument should be required for the same reason. (Of course web compat may preclude that, but that's incidental.) The "convenience" of the optional descriptor argument and optional initial property is in reality just a footgun. |
Ah, maybe I'm looking at a stale doc then, but in https://webassembly.github.io/spec/js-api/index.html#memories, |
@lukewagner That's right--in WebIDL, I believe dictionaries default to optional and note required, whereas parameters default to required and note optional. |
In JS if Following @lars-t-hansen comment about footgun; when you import a WebAssembly.Memory and the initial is smaller that the one declared in Wasm, it throws. So I think this kind of the errors will be catched. Also, I would be happy to send a PR if once we have a resolution. PS: the Table constructor has the same issue. |
Is a PR needed? Maybe we should stick with the current semantics, per the comments from @lars-t-hansen . Otherwise, if we want to stick with WebIDL conventions while preserving the optionality, I guess we would make the dictionary field optional and the existence of the dictionary parameter optional. |
A PR is need in all cases because the spec has the two conflicting behaviors. |
Right, of course. Does anyone want to make a PR to delete the dead line that @Ms2ger mentions? |
I can do it, for Memory and Table. I'm also updating the v8 implementation by the way. |
Somewhat simplified, the spec has:
but then the prose goes on to say
while this line is unreached if descriptor["initial"] is not present, because IDL will throw an exception before calling into the spec's prose.
The text was updated successfully, but these errors were encountered: