-
Notifications
You must be signed in to change notification settings - Fork 164
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
Consider disallowing optional dictionary arguments that have required members #793
Comments
I should note that there are no cases like the one I am proposing disallowing in the parts of the web platform Gecko implements right now, and in fact Gecko's code generator fails out in that situation. That is not what prompted me to file this issue; @foolip's comments in w3c/webidl2.js#407 did, but it's a data point in terms of whether people would be affected in practice. |
Makes sense to me.
I think we might as well disallow it. |
See #76 (comment) -- people are using that pattern in specs... |
Only for dictionary members, right? I see no special value to allow it for arguments, where things like whatwg/html#5064 is just broken and not really optional. BTW, do you recall which specs use that pattern? |
https://w3c.github.io/media-capabilities/#media-configurations is an example. |
Consider this IDL:
This is currently allowed by the spec. But in terms of behavior, what does the implementation of
bar
do if the dictionary is not passed? Specifically, what does it use in the place where it was going to usemyVal
? I can see a few options:It treats it effectively as a tristate, with no value if the dictionary was not passed. But then it could just make it optional in the dictionary too.
It assumes a value for
myVal
(true
orfalse
). Then it could just make it optional in the dictionary and give it a default value.Either way, it doesn't make sense to have this dictionary member be required in this situation. Hence I would propose that we disallow optional arguments whose type is a dictionary with required members. It might still make sense to have optional dictionary members whose type is a dictionary that has required members, I guess...
@domenic @annevk @saschanaz @Ms2ger thoughts?
The text was updated successfully, but these errors were encountered: