[heycam/webidl] Consider disallowing optional dictionary arguments that have required members (#793)

Consider this IDL:
```
dictionary X {
  required boolean myVal;
};

interface Foo {
  void bar(optional X arg);
};
```
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 use `myVal`? 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` or `false`).  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?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/issues/793

Received on Thursday, 5 September 2019 13:59:51 UTC