Re: [heycam/webidl] Reword the distinguishability algorithm. (#194)

bzbarsky commented on this pull request.



>  
-1.  The two types (taking their [=inner types=]
+<ol class="algorithm">
+1.  If both types are either a [=union type=] or nullable union type,

This will do the wrong thing if both types are nullable union types, no?  That is, it could return true, when it should return false.

In fact, the union handling in these proposed changes seems all wrong to me.  Please explain to me why, with the new wording changes, the following type pairs are _not_ distinguishable (which is what they should be):

1. `(Node or long)?` and `(Location or DOMString)?`
2. `(Node or long?)` and `(Location or DOMString)?`
3. `(Node or long?)` and `(Location or DOMString?)`
4. `(SomeDictionary or long)` and `(Location or DOMString)?`
5. `(SomeDictionary or long)` and `(Location or DOMString?)`

Note that 4 and 5 are not right in the spec as it currently stands either.  :(

I should also say that I the note after the paragraph defining <https://heycam.github.io/webidl/#dfn-nullable-type> is pretty confusing.  Of course I think it's rather weird that we disallow `void foo(DictionaryType? arg)` but allow `void foo(sequence<DictionaryType?> arg)`....  For what it's worth, Gecko's code generator actually explicitly disallows this "sequence of nullable dictionaries as an argument" thing, even though our parser allows it through, since IDL technically allows it.

I'm not sure how to cleanly disallow that while allowing `sequence<DictionaryType?>` as a return value, where it can make sense, short of just defining somewhat different syntax for "argument types" and "return value types" in general or something.  :(

But certainly the five cases listed above should be made to work, because while a UA could in fact implement arguments of type `sequence<DictionaryType?>` if it really wanted to (mapping `null` to the IDL null value, not empty dictionary), the five examples above really don't allow distinguishing which of the two things should be picked if `null` is the provided value.

-- 
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/pull/194#pullrequestreview-4792653

Received on Wednesday, 19 October 2016 01:55:15 UTC