Elision following AssignmentRestElement should not be permitted

RESOLVED DUPLICATE of bug 1041341

Status

()

RESOLVED DUPLICATE of bug 1041341
4 years ago
4 years ago

People

(Reporter: jugglinmike, Unassigned)

Tracking

(Blocks: 1 bug)

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

4 years ago
$ js -e "[...x , ] = [1, 2, 3];"

Expected: SyntaxError
Actual: successful execution (an new array, `[1, 2, 3]` is assigned to `x`)

Additional elisions are incorrectly rejected, i.e.

    $ js -e "[...x , , ] = [1,2,3]; print(x);"
    -e:1:8 SyntaxError: parameter after rest parameter:
    -e:1:8 [...x , , ] = [1,2,3]; print(x);
    -e:1:8 ........^

Relevant grammar (ES6 12.14.5 Destructuring Assignment):

> ArrayAssignmentPattern[Yield] :
>   [ Elisionopt AssignmentRestElement[?Yield]opt ]
>   [ AssignmentElementList[?Yield] ]
>   [ AssignmentElementList[?Yield] , Elisionopt AssignmentRestElement[?Yield]opt ]
> 
> AssignmentRestElement[Yield] :
>   ... DestructuringAssignmentTarget[?Yield]
> 
> DestructuringAssignmentTarget[Yield] :
>   LeftHandSideExpression[?Yield]

Source: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-destructuring-assignment

Build details:

commit 07bb578e6a93d11a3e1365e2b0d9296a755543ee
Date:   Fri Apr 17 13:52:50 2015 -0700
(Reporter)

Comment 1

4 years ago
Updating to confirm that this is still an issue with the latest build:

    $ js -e "[...x , ] = [1]; print(x);"
    1
    $ js -e "[...x , , ] = [1]; print(x);"
    -e:1:8 SyntaxError: parameter after rest parameter:
    -e:1:8 [...x , , ] = [1]; print(x);
    -e:1:8 ........^

commit 09631fba2e955162f3ffbbdc4f4a5c8b9c926ead
Date   Mon May 18 13:43:01 2015 +0200
Blocks: 694100
This is basically a dupe of bug 1041341.
Status: NEW → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 1041341
You need to log in before you can comment on or make changes to this bug.