Open bzbarsky opened 5 years ago
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 https://github.com/w3c/webidl2.js/issues/407 did, but it's a data point in terms of whether people would be affected in practice.
Hence I would propose that we disallow optional arguments whose type is a dictionary with required members.
Makes sense to me.
It might still make sense to have optional dictionary members whose type is a dictionary that has required members, I guess...
I think we might as well disallow it.
I think we might as well disallow it.
See https://github.com/heycam/webidl/issues/76#issuecomment-393899041 -- people are using that pattern in specs...
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 https://github.com/whatwg/html/issues/5064 is just broken and not really optional.
BTW, do you recall which specs use that pattern?
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:1) 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.
2) 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?