Skip to content

Commit d70208e

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 7349ff4 commit d70208e

File tree

3 files changed

+284
-4
lines changed

3 files changed

+284
-4
lines changed

src/jshint.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -3467,7 +3467,8 @@ var JSHINT = (function() {
34673467
}
34683468
};
34693469
var assignmentProperty = function() {
3470-
var id;
3470+
var id, expr;
3471+
34713472
if (checkPunctuator(state.tokens.next, "[")) {
34723473
advance("[");
34733474
expression(10);
@@ -3488,7 +3489,16 @@ var JSHINT = (function() {
34883489
warning("W144", state.tokens.next, "object rest property", "objspreadrest");
34893490
}
34903491

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

0 commit comments

Comments
 (0)