Re: Nullable union types containing other nullable types

Boris Zbarsky:
> Consider this idl:
>
>    void foo((A? or B)? arg);
>
> Is this allowed?  At first glance, it is.

No, in #idl-nullable-type it says:

   The inner type MUST NOT be any or another nullable type or a union
   type that itself has a nullable type as a member type, as they
   already allow the null value.

> Should this be allowed?  I guess there's no reason it shouldn't be; it
> just seems weird to write IDL like that...  Passing null or undefined
> would just convert to IDL null because the union is nullable, o the '?'
> after A is just pointless, right?

Yeah, I don't think there's any real need to allow this.  (It let me 
simplify some language dealing with union types this way, too.)

The only reason we *might* like to allow this is if you had a typedef 
for some type that was nullable:

   typedef sequence<long>? Numbers;
   typedef sequence<DOMString>? Letters;

which meant that you couldn't write for example

   void f((Numbers or Letters) x);

and you'd need to expand out the typedef.  Probably not something that 
would come up often, though.

Received on Saturday, 14 April 2012 03:43:42 UTC