]> code.delx.au - gnu-emacs-elpa/commit
Implement object literal rest/spread (...)
authorDavid Greenspan <dgreenspan@alum.mit.edu>
Wed, 11 Nov 2015 00:40:04 +0000 (16:40 -0800)
committerDavid Greenspan <dgreenspan@alum.mit.edu>
Wed, 11 Nov 2015 00:40:04 +0000 (16:40 -0800)
commit2a904e08fe3e009409ccfb8f928fab43f7efaeed
tree84625da3cd2e3af9cdf9cd1b9c982cb1fc26fb9b
parent7fe716506b3e8536446c1a83a54e4b3c8d39f361
Implement object literal rest/spread (...)

As discussed in #245, this syntax is not part of ES6/2015, but it is
a stage 2 proposal, meaning the committee expects it to be included
in the standard.  It's already seeing heavy use by e.g. the React
community.

This change causes `...expr` in an object literal to be parsed as a
unary-node element of an object-node, and modifies places where an
element of an object-node is expected to be an infix-node.  Note that
only weak typing assumptions are made already about object-node elems.

In addition, this change implements proper name extraction in
object literal destructuring.  The cases are:

1. `let {a} = x;`
2. `let {a: b} = x;` (should define `b`)
3. `let {a = b} = x;` (should define `a`)
4. `let {...a} = x;` (should define `a`)

This change fixes case (2), which was broken, and adds case (4).
js2-mode.el
tests/parser.el