Skip to content

Commit fedd461

Browse files
committed
[[FIX]] Update parsing of object "rest" property
The latest version of the proposal disallows BindingPattern as the right-hand side of a "rest" property. tc39/proposal-object-rest-spread#50 http://tc39.github.io/tc39-notes/2017-05_may-23.html#16ih-why-allow-bindingpattern-for-bindingrestparameter-for-object-rest-maybe-we-should-just-allow-identifiers
1 parent a8eb927 commit fedd461

File tree

3 files changed

+284
-4
lines changed

3 files changed

+284
-4
lines changed

src/jshint.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3462,7 +3462,8 @@ var JSHINT = (function() {
34623462
}
34633463
};
34643464
var assignmentProperty = function() {
3465-
var id;
3465+
var id, expr;
3466+
34663467
if (checkPunctuator(state.tokens.next, "[")) {
34673468
advance("[");
34683469
expression(10);
@@ -3483,7 +3484,16 @@ var JSHINT = (function() {
34833484
warning("W143", state.tokens.next, "object rest property", "objspreadrest");
34843485
}
34853486

3486-
nextInnerDE();
3487+
// Due to visual symmetry with the array rest property (and the early
3488+
// design of the language feature), developers may mistakenly assume
3489+
// any expression is valid in this position. Parse an expression and
3490+
// issue an error in order to recover more gracefully from this
3491+
// condition.
3492+
expr = expression(10);
3493+
3494+
if (expr.type !== "(identifier)") {
3495+
error("E030", expr, expr.value);
3496+
}
34873497
} else {
34883498
id = identifier();
34893499
}

0 commit comments

Comments
 (0)