Continuing woes in reading the ES6 spec language

Allen Wirfs-Brock allen at
Thu Sep 12 13:30:34 PDT 2013

On Sep 12, 2013, at 12:45 PM, Oliver Hunt wrote:

> On Sep 12, 2013, at 12:40 PM, Jason Orendorff <jason.orendorff at> wrote:
>> Just as a worked example, answering Oliver's question about default
>> expressions took me the better part of an hour.
>> The default-expression h() in code like
>>   function f(x=h(), y) {
>>       function h() { ... }
>>   }
>> is evaluated in the scope of f, as I expected, so {x, h, y} are all in
>> scope there.
>> But I was surprised by the timing; h() is evaluated
>> (a) before y is populated with the actual argument value;
>> (b) before the arguments object is fully initialized.
>> That last surprise seems really unfortunate, since the expression can
>> access the arguments object, observing it before and after
>> CompleteMapped/StrictArgumentsObject, or even cause those to fail. Can
>> we change that?
> From talking to SpiderMonkey folk it sounds like SM nukes the |arguments| identifier entirely if you use any of the new parameter logic (deconstruction, defaults, or rest params).  I would be happy with that.

That isn't we agreed to within TC39, as I recall.  Instead, if the parameter list uses any new syntax (see the IsSimpleParameterList static semantic routine in 14.1) then it gets an array-like  arguments object, just like a strict function gets. This should be accounted for in Function Declaration Instantiation but apparently isn't.  That's a spec. bug that I'll fixed.

Other static restrictions on formal parameters are defined in the Early Error section of 14.1.

Function Declaration Instantiation current only initializes the arguments binding at its very end, after initializing all the formal parameters in step 21.  So, as currently spec. any reference to arguments in a default value initializer should throw.  I believe this is wrong, step 23 (initializing arguments) needs to move above step 21.

> The spec (from my understanding) says that we can't declare a parameter named arguments but does limit reads of it.  Also that doesn't limit declarations of a local named arguments 

See early errors for BindingIdentifer in 13.2.  In strict code, it is always illegal to declare 'eval' or 'arguments' using any binding form.

In general, I suggest asking me things, before spending too much time puzzling things out.  There are spec. bugs and things that are missing and if something.  If you can;t figure it out relatively quickly let me know.  It is quite likely to be a bug, or an indication of an area where I need to add clarifying material.


More information about the es-discuss mailing list