This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 23602 - "optional any" is nonsense that should be disallowed
Summary: "optional any" is nonsense that should be disallowed
Status: NEW
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: WebIDL (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Cameron McCormack
QA Contact: public-webapps-bugzilla
Depends on:
Reported: 2013-10-23 06:39 UTC by Boris Zbarsky
Modified: 2016-08-29 13:30 UTC (History)
3 users (show)

See Also:


Description Boris Zbarsky 2013-10-23 06:39:25 UTC
Or perhaps non-optional any is nonsense?

In any case, passing "undefined" to an "any" argument should presumably simply preserve the "undefined" value, and it looks like in fact specifies that.  Given that we no longer differentiate between "undefined" and "omitted", what should passing "undefined" to an "optional any" do?  It seems weird to treat that as "omitted" when the "any" type can in fact represent the value.

I would argue that we should simply not have optional vs non-optional any: have only "any", where it can always be not passed or explicitly passed as "undefined", in which case it coerces the value to "undefined".
Comment 1 Cameron McCormack 2013-10-23 06:49:15 UTC
If we do that then we should do something similar for dictionary members, making

  dictionary A {
    any x;

  interface B {
    void f(A a);

  b.f({ x: undefined });

mean that x is present with the undefined value, rather than not present as is currently specced.
Comment 2 Boris Zbarsky 2013-10-23 06:53:08 UTC
Yes, I agree.

Basically, either we should remove "undefined" from the allowed value set of "any" (and then all "any" arguments should be optional and undefined becomed "not present") or we should keep "undefined" in the value set and simply have "undefined" become the "undefined" value.
Comment 3 Anne 2013-10-23 09:42:26 UTC
I think the latter solution of comment 2 makes the most sense.
Comment 4 Anne 2016-08-29 06:32:23 UTC
Did this got resolved? I think we made some changes to undefined handling since 2013-10.
Comment 5 Boris Zbarsky 2016-08-29 13:30:41 UTC
I don't think this got resolved, no.  I never got any feedback from other implementors on my proposal at so I just went ahead and implemented a modified version of it in Gecko; see <>.  The difference between what I implemented and the proposal on the list is whether trailing non-optional "any" affects the argc check behavior....  But in the spec right now, as far as I can tell, "optional any" can only take on the state "not passed", and can't have the state "undefined".  That's what I aimed to fix in my Gecko changes; in Gecko the "optional" bit just affects .length and argc checks, but the value is always considered "passed" and may just have the value "undefined".