According to the ES6 spec, <http://www.ecma-international.org/ecma-262/6.0/#sec-function-definitions-static-semantics-early-errors>, reusing the function name of a function as a parameter name should not throw a Syntax Error. This is was pointed out on the es-discuss mailing list <https://esdiscuss.org/topic/can-strict-parameters-shadow-strict-function-names>, specifically how we differ from V8 and SpiderMonkey.
Created attachment 280959 [details] Patch
<rdar://problem/26729710>
Comment on attachment 280959 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=280959&action=review r=me with comments > Source/JavaScriptCore/parser/Parser.h:483 > + bool isValidStrictMode = (addResult.isNewEntry || !addResult.iterator->value.isParameter()) > + && m_vm->propertyNames->eval != *ident && !isArgumentsIdent; Style: one line > LayoutTests/js/script-tests/basic-strict-mode.js:89 > +shouldBe("(function a(a){'use strict'; return a+2; })(40)", "42"); > +shouldBe("var foo = function a(a){'use strict'; return a+2; }; foo(40)", "42"); Can you also add tests for method style syntax?
Comment on attachment 280959 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=280959&action=review > Source/JavaScriptCore/ChangeLog:10 > + The check for a parameter with a duplicate name doesn't take into account the > + type of the prior variable. Added a check that the duplicate is also a > + parameter. Can you add the URL to the spec as a ref here?
(In reply to comment #3) > Comment on attachment 280959 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=280959&action=review > > r=me with comments > > > Source/JavaScriptCore/parser/Parser.h:483 > > + bool isValidStrictMode = (addResult.isNewEntry || !addResult.iterator->value.isParameter()) > > + && m_vm->propertyNames->eval != *ident && !isArgumentsIdent; > > Style: one line Our style guide doesn't talk about whether or not we should break long line. I believe this is more readable. The breaking is in line with the style guide. > > LayoutTests/js/script-tests/basic-strict-mode.js:89 > > +shouldBe("(function a(a){'use strict'; return a+2; })(40)", "42"); > > +shouldBe("var foo = function a(a){'use strict'; return a+2; }; foo(40)", "42"); > > Can you also add tests for method style syntax? Done.
(In reply to comment #4) > Comment on attachment 280959 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=280959&action=review > > > Source/JavaScriptCore/ChangeLog:10 > > + The check for a parameter with a duplicate name doesn't take into account the > > + type of the prior variable. Added a check that the duplicate is also a > > + parameter. > > Can you add the URL to the spec as a ref here? Done.
Committed r201892: <http://trac.webkit.org/changeset/201892>