Re: [heycam/webidl] undefined can't be a member of a union type (#962)

> since IDL undefined is forbidden in arguments and in dictionaries

Yes, it's forbidden *only* in those places. It's allowed in return types, attribute types, etc.

(And it's only forbidden in those places because we have `optional` filling the same purpose.)

> I would err on the side of them not being distinguishable.

Works for me. I've edited the distinguishability table, and that means I can still add a rule checking for undefined in the union.

------

New question now that I've reviewing more here - currently, the spec says that `undefined` satisfies a nullable type (first step of <https://heycam.github.io/webidl/#es-union>).

So, per current spec, you can satisfy an IDL `Foo?` type with a JS `undefined`. That implies that `(Foo? or undefined)` should be invalid due to lack of distinguishability, right? (So I need to augment step 1 of <https://heycam.github.io/webidl/#dfn-distinguishable> to also mention undefined.)

But the opposite is *not* true - you can't satisfy a IDL `undefined` type with a JS `null`, so an IDL `undefined?` type still makes sense, right? (And so I do *not* need to modify <https://heycam.github.io/webidl/#dfn-nullable-type> to exclude undefined.)

(This didn't come up in the previous `void` case, since `void` couldn't be combined with things in this way...)

-- 
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/962#issuecomment-797839471

Received on Saturday, 13 March 2021 01:12:36 UTC