Can strict parameters shadow strict function names?

Bergi a.d.bergi at web.de
Thu Jun 9 17:58:08 UTC 2016


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.

> We are running into this when loading the output of a minifier as strict
> code.

Guess you should file a bug there - it a) doesn't make sense to name a 
function expression (does it ever in minified code) and use the same 
name for a parameter b) it should not fail in real-world engines even if 
the spec says something else.

Regards,
  Bergi


More information about the es-discuss mailing list