Bug 162013 - test262: Should be a SyntaxError for duplicate parameter names in function with default parameters
Summary: test262: Should be a SyntaxError for duplicate parameter names in function wi...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Joseph Pecoraro
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-15 02:08 PDT by Joseph Pecoraro
Modified: 2016-09-15 08:43 PDT (History)
5 users (show)

See Also:


Attachments
[PATCH] Proposed Fix (8.70 KB, patch)
2016-09-15 02:15 PDT, Joseph Pecoraro
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2016-09-15 02:08:56 PDT
Summary:
Should be a SyntaxError for duplicate parameter names in function with default parameters

Currently we only issue a SyntaxError if their is a duplicate name and it or later there is default parameter value:

    jsc> function f(x, x = 0) {}
    Duplicate parameter 'x' not allowed in function with default parameter values.:1

We should, but aren't, issuing the same SyntaxError if there is a duplicate name and there was an earlier default parameter values.

    jsc> function f(x = 0, x) {}
    undefined

We should be issuing a SyntaxError if there is a duplicate name if there are any default parameters.

Spec:
https://tc39.github.io/ecma262/#sec-function-definitions-static-semantics-early-errors

> FormalParameters : FormalParameterList
> 
>     It is a Syntax Error if IsSimpleParameterList of FormalParameterList is
>     false and BoundNames of FormalParameterList contains any duplicate elements.

https://tc39.github.io/ecma262/#sec-destructuring-binding-patterns-static-semantics-issimpleparameterlist

IsSimpleParameterList is false if the parameter list contains
things like any RestParameters, BindingPatterns (destructuring),
or BindingIdentifiers with Initialization (default parameters).

Notes:
- Covered in a bunch of test262 tests, like:
test262/test/language/expressions/function/params-dflt-duplicates.js
Comment 1 Joseph Pecoraro 2016-09-15 02:15:28 PDT
Created attachment 288944 [details]
[PATCH] Proposed Fix
Comment 2 WebKit Commit Bot 2016-09-15 08:43:03 PDT
Comment on attachment 288944 [details]
[PATCH] Proposed Fix

Clearing flags on attachment: 288944

Committed r205969: <http://trac.webkit.org/changeset/205969>
Comment 3 WebKit Commit Bot 2016-09-15 08:43:06 PDT
All reviewed patches have been landed.  Closing bug.