-
Notifications
You must be signed in to change notification settings - Fork 165
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
void -> undefined, and allow it anywhere. #906
Conversation
index.bs
Outdated
@@ -2520,7 +2525,6 @@ steps are:” followed by a list, or “The <code>|operation|(<var ignore>arg1</ | |||
<pre class="grammar" id="prod-ReturnType"> | |||
ReturnType : | |||
Type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really, but I left it in because maybe it's useful to distinguish that in the future? I can just fold it away if y'all think that would be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's fold it away; I think a big win of this PR is unifying the two value spaces.
@@ -14547,7 +14549,7 @@ are passed to it or what kind of value is returned from it. | |||
|
|||
<h3 id="VoidFunction" callback>VoidFunction</h3> | |||
|
|||
<pre class="idl">callback VoidFunction = void ();</pre> | |||
<pre class="idl">callback VoidFunction = undefined ();</pre> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be UndefinedFunction
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't think it was worth changing the name there, and requiring all users of VoidFunction to update. It's still a meaningful name post-update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that 4 specs in reffy-reports use VoidFunction: CSS Layout, CSS Paint, HTML, and WebRTC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, this turned out simpler than I expected. I guess the actual change, e.g. allowing it in unions, falls out of changing the grammar?
Let's fold in Type into ReturnType. Then we should make sure we're ready for a big spec update of this magnitude before merging:
- File issues on all the places located in https://github.com/heycam/webidl#filing-issues-elsewhere, pointing to this about-to-be-merged PR.
- @saschanaz, can you get your bot ready to pull request all the specs?
- /cc @foolip and @stephenmcgruer who has been doing some IDL stuff, I think related to reffy reports. (Maybe reffy should also go in that list of places to file issues?)
index.bs
Outdated
@@ -2520,7 +2525,6 @@ steps are:” followed by a list, or “The <code>|operation|(<var ignore>arg1</ | |||
<pre class="grammar" id="prod-ReturnType"> | |||
ReturnType : | |||
Type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's fold it away; I think a big win of this PR is unifying the two value spaces.
Sure, but the code currently does not support HTML and WebGL, as those specs manually decorate their IDL while others have pure IDL. Patching those two should thus be manual. |
Yup, just had to make it a PrimitiveType, rather than a special ReturnType only.
Two votes for, so new commit coming shortly. |
Will get to that shortly, thanks for the pointer. |
index.bs
Outdated
@@ -1791,11 +1791,17 @@ The following extended attributes are applicable to constants: | |||
|
|||
<pre class="grammar" id="prod-ConstValue"> | |||
ConstValue : | |||
UndefinedLiteral |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this for #905?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, unrelated. It just looked correct, since I was adding a new literal, that it should be added to the Const productions as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this PR uses the new literal elsewhere? I think this is the only use.
Perhaps this should be deferred to #905?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this PR uses the new literal elsewhere? I think this is the only use.
No, this is it. But the other primitives all have a literal, except null (which is a little weird, but it's handled as a type annotation rather than a type on its own, so eh).
I could remove this if necessary, it just seemed nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd probably be better to avoid unnecessary indirections in the grammar.
Does an argument typed |
By itself, like |
I think |
Good point... Hmm. Is that something that the grammar can prevent? Otherwise we should add a prose restriction. |
It is, but it would require adding Like I said, tho, I don't think this is a footgun that we actually need to protect anyone against. We can put in a prose restriction if y'all feel it's absolutely necessary, but I really don't want to enforce this in the grammar. |
I think this is pretty important to enforce in the grammar. |
Agreed, it would be very verbose to force it in the grammar. It should probably be okay to just write a prose, as WPT has a validator that should prevent authors to do that. |
I don't understand why it's important to avoid verbosity in the grammar here. What else is the grammar for, if not to enforce restrictions of this sort? |
Oh dang, upon review it would actually be even worse than I thought to handle in the grammar - I'd have to split the typedef production as well so that typedefs with an
Overall, simple grammars are better because they're easier to read and understand, and easier to maintain over time without mistakes or oversights. Grammar simplicity is mostly a "spec author" convenience in the priority of constituencies, slightly a "UA author" issue.
"Of this sort", sure. My objection is that this isn't actually a restriction worth enforcing in the first place, so it's not worth adding a bunch of complexity for. We should add restrictions when we think spec authors will actually make a mistake that they'd appreciate being informed about. If we're really concerned with people doing |
I think this is a very important that people not use |
Ah yeah, and on further consideration, even if I split the grammar it wouldn't help, because doing so would also strongly break the LL(1) nature of the grammar, instead now requiring infinite lookahead to parse (because an I'll remove the const bit and add a prose restriction, one sec. |
…as a const value and forbid it from being an argument type.
I guess it might not make sense on dictionaries either. I wonder we should allow it only at return type position and some template parameters including Promise. |
(Sorry, deleted previous comment, I was misreading.)
Hm, because dictionary entries can be marked as "optional" too? |
Yeah, the entries are optional by default so |
Well, we definitely want attributes which return undefined OR something else. But I agree restricting dictionaries is a good idea. (In particular, if we didn't restrict dictionaries, then spec authors would have to choose between setting their dictionary members to undefined vs. leaving them absent... ugh.) |
This change to the parser at the moment is only internal, and in this commit an affected override is corrected accordingly. IDL files still cal use `void` at the moment. Chromium change: https://chromium.googlesource.com/chromium/src/+/5e8a1af4b7b9bb9a7d2948758b41ef3bf9abc36f commit 5e8a1af4b7b9bb9a7d2948758b41ef3bf9abc36f Author: Yuki Shiino <[email protected]> Date: Wed Nov 1 15:08:24 2023 +0000 bindings: Rename 'void' to 'undefined' in bindings/scripts/ This patch renames only the internal implementation code in web_idl/ and bind_gen/, and doesn't rename any IDL code in *.idl files. Web IDL 2.13.2. undefined https://webidl.spec.whatwg.org/#idl-undefined See also whatwg/webidl#906 Bug: 1116522
This change to the parser at the moment is only internal, and in this commit an affected override is corrected accordingly. IDL files still cal use `void` at the moment. Chromium change: https://chromium.googlesource.com/chromium/src/+/5e8a1af4b7b9bb9a7d2948758b41ef3bf9abc36f commit 5e8a1af4b7b9bb9a7d2948758b41ef3bf9abc36f Author: Yuki Shiino <[email protected]> Date: Wed Nov 1 15:08:24 2023 +0000 bindings: Rename 'void' to 'undefined' in bindings/scripts/ This patch renames only the internal implementation code in web_idl/ and bind_gen/, and doesn't rename any IDL code in *.idl files. Web IDL 2.13.2. undefined https://webidl.spec.whatwg.org/#idl-undefined See also whatwg/webidl#906 Bug: 1116522
This change to the parser at the moment is only internal, and in this commit an affected override is corrected accordingly. IDL files still cal use `void` at the moment. Chromium change: https://chromium.googlesource.com/chromium/src/+/5e8a1af4b7b9bb9a7d2948758b41ef3bf9abc36f commit 5e8a1af4b7b9bb9a7d2948758b41ef3bf9abc36f Author: Yuki Shiino <[email protected]> Date: Wed Nov 1 15:08:24 2023 +0000 bindings: Rename 'void' to 'undefined' in bindings/scripts/ This patch renames only the internal implementation code in web_idl/ and bind_gen/, and doesn't rename any IDL code in *.idl files. Web IDL 2.13.2. undefined https://webidl.spec.whatwg.org/#idl-undefined See also whatwg/webidl#906 Bug: 1116522
This change to the parser at the moment is only internal, and in this commit an affected override is corrected accordingly. IDL files still cal use `void` at the moment. Chromium change: https://chromium.googlesource.com/chromium/src/+/5e8a1af4b7b9bb9a7d2948758b41ef3bf9abc36f commit 5e8a1af4b7b9bb9a7d2948758b41ef3bf9abc36f Author: Yuki Shiino <[email protected]> Date: Wed Nov 1 15:08:24 2023 +0000 bindings: Rename 'void' to 'undefined' in bindings/scripts/ This patch renames only the internal implementation code in web_idl/ and bind_gen/, and doesn't rename any IDL code in *.idl files. Web IDL 2.13.2. undefined https://webidl.spec.whatwg.org/#idl-undefined See also whatwg/webidl#906 Bug: 1116522
This change to the parser at the moment is only internal, and in this commit an affected override is corrected accordingly. IDL files still cal use `void` at the moment. Chromium change: https://chromium.googlesource.com/chromium/src/+/5e8a1af4b7b9bb9a7d2948758b41ef3bf9abc36f commit 5e8a1af4b7b9bb9a7d2948758b41ef3bf9abc36f Author: Yuki Shiino <[email protected]> Date: Wed Nov 1 15:08:24 2023 +0000 bindings: Rename 'void' to 'undefined' in bindings/scripts/ This patch renames only the internal implementation code in web_idl/ and bind_gen/, and doesn't rename any IDL code in *.idl files. Web IDL 2.13.2. undefined https://webidl.spec.whatwg.org/#idl-undefined See also whatwg/webidl#906 Bug: 1116522
This change to the parser at the moment is only internal, and in this commit an affected override is corrected accordingly. IDL files still cal use `void` at the moment. Chromium change: https://chromium.googlesource.com/chromium/src/+/5e8a1af4b7b9bb9a7d2948758b41ef3bf9abc36f commit 5e8a1af4b7b9bb9a7d2948758b41ef3bf9abc36f Author: Yuki Shiino <[email protected]> Date: Wed Nov 1 15:08:24 2023 +0000 bindings: Rename 'void' to 'undefined' in bindings/scripts/ This patch renames only the internal implementation code in web_idl/ and bind_gen/, and doesn't rename any IDL code in *.idl files. Web IDL 2.13.2. undefined https://webidl.spec.whatwg.org/#idl-undefined See also whatwg/webidl#906 Bug: 1116522
This change to the parser at the moment is only internal, and in this commit an affected override is corrected accordingly. IDL files still cal use `void` at the moment. Chromium change: https://chromium.googlesource.com/chromium/src/+/5e8a1af4b7b9bb9a7d2948758b41ef3bf9abc36f commit 5e8a1af4b7b9bb9a7d2948758b41ef3bf9abc36f Author: Yuki Shiino <[email protected]> Date: Wed Nov 1 15:08:24 2023 +0000 bindings: Rename 'void' to 'undefined' in bindings/scripts/ This patch renames only the internal implementation code in web_idl/ and bind_gen/, and doesn't rename any IDL code in *.idl files. Web IDL 2.13.2. undefined https://webidl.spec.whatwg.org/#idl-undefined See also whatwg/webidl#906 Bug: 1116522
Fixes #60