Can strict parameters shadow strict function names?

Andreas Rossberg rossberg at google.com
Thu Jun 9 18:15:46 UTC 2016


On 9 June 2016 at 19:58, Bergi <a.d.bergi at web.de> wrote:

> Mark S. Miller wrote:
>
>> var foo = function bar(bar) {'use strict'};
>>
>> On all version of Safari/JSC I just tested, this code gives a
>> SyntaxError: Invalid parameters or function name in strict mode.
>>
>> On all versions of Chrome/v8 and FF/SpiderMonkey I just tested, this code
>> is accepted without error.
>>
>> Which behavior is incorrect?
>>
>
> This appears to be a bug in Safari/JSC.
>
> Is this an ES5 vs ES2015 issue?
>>
>
> No, both ES5 <http://es5.github.io/#x13.1> and ES6 <
> http://www.ecma-international.org/ecma-262/6.0/#sec-function-definitions-static-semantics-early-errors>
> only have a syntax error if there are duplicate *parameter* names,
> regardless of the name of the function.


In particular, the function name is in its own singleton scope outside the
parameter scope. My guess is that this semantics was chosen so that
collision doesn't differ between function declarations and expressions.

/Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160609/41f21834/attachment.html>


More information about the es-discuss mailing list