W3C home > Mailing lists > Public > public-script-coord@w3.org > October to December 2012

Interaction of dictionaries and platform objects is a bit weird

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Wed, 17 Oct 2012 22:08:39 -0400
Message-ID: <507F64A7.2010303@mit.edu>
To: "public-script-coord@w3.org" <public-script-coord@w3.org>
Consider the following IDL:

   dictionary Dict {
     long a;
   interface Iface {
     void foo(long x, optional Dict y);
     void bar(optional Dict z);
     void bar(Element w);

and this script, running in a web page:

   var x = new Iface();
   x.foo(5, document);

What happens?

As far as I can tell, the foo() call succeeds.  The "a" property of the 
document, if any, is placed in the dictionary, and then the number 5 and 
the dictionary are passed to the WebIDL method implementation.

Also as far as I can tell the call bar() call throws.  This is because 
we enter the overload resolution algorithm, set argcount to 1, throw our 
the 0-argument overload, set d to 0, examine arg 0, determine that it 
does not satisfy either overload (because document does not implement 
Element and because document is a platform object, so never enters step 
13.6 of the overload resolution algorithm), and a TypeError is thrown.

This seems a bit odd.  I think we should either always throw a TypeError 
when converting platform objects to dictionaries or allow any object to 
enter step 13.6 of overload resolution... at least for dictionaries; not 
sure about callbacks.  Maybe dictionaries need to be split out into a 
separate step here?

Received on Thursday, 18 October 2012 02:09:08 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:07 UTC