WebIDL overload resolution, arrays and Nullable

Over in WebKit-land there's some disagreement about WebIDL method overload
resolution, specifically around passing null, arrays (T[]) and the concept
of Nullable.

Here's an example where we're just not sure what the WebIDL spec dictates:

void f(float[] x); // overload A
void f(DOMString x); // overload B

WebIDL itself, of course, doesn't dictate how matching and dispatching
should be implemented; it instead defines whether types are
distinguishable. The implication is that an IDL that defines methods with
signatures that are not distinguishable is invalid, so it's a non-issue in
terms of the spec. So rephrasing the question: are the above types
distinguishable? And if so, which would be expected to handle the call:

f(null);

Several interpretations and hence outcomes occur to us, hopefully presented
without indicating my particular bias:

(1) T[] is inherently Nullable (i.e. T[] === T[]?), DOMString is not,
overload A would be invoked with a null argument and the implementation is
expected to handle this case
(2) T[] accepts null but the IDL type to ECMAScript conversion rules
produce an empty array; overload A is invoked with an empty float array
(3) T[] does not match null, but as null is an ECMAScript primitive value
it is run through ToString() and hence overload B is invoked with DOMString
"null"
(4) Either T[] or DOMString could match null, so types of the arguments are
not distinguishable and hence the above is invalid WebIDL
(5) Neither T[] nor DOMString is inherently Nullable, so a TypeError is
thrown

Anyone? (Cameron?)

Received on Friday, 29 June 2012 16:25:37 UTC