Verify that property name can be bound to in short-hand object pattern properties
Issue #221
This commit is contained in:
parent
a45172e044
commit
9673146cc1
10
acorn.js
10
acorn.js
@ -2492,13 +2492,11 @@
|
|||||||
if (this.options.ecmaVersion >= 6) {
|
if (this.options.ecmaVersion >= 6) {
|
||||||
prop.method = false;
|
prop.method = false;
|
||||||
prop.shorthand = false;
|
prop.shorthand = false;
|
||||||
if (isPattern || refShorthandDefaultPos) {
|
if (isPattern || refShorthandDefaultPos)
|
||||||
start = this.currentPos();
|
start = this.currentPos();
|
||||||
}
|
if (!isPattern)
|
||||||
if (!isPattern) {
|
|
||||||
isGenerator = this.eat(tt.star);
|
isGenerator = this.eat(tt.star);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
this.parsePropertyName(prop);
|
this.parsePropertyName(prop);
|
||||||
if (this.eat(tt.colon)) {
|
if (this.eat(tt.colon)) {
|
||||||
prop.value = isPattern ? this.parseMaybeDefault() : this.parseMaybeAssign(false, refShorthandDefaultPos);
|
prop.value = isPattern ? this.parseMaybeDefault() : this.parseMaybeAssign(false, refShorthandDefaultPos);
|
||||||
@ -2518,6 +2516,10 @@
|
|||||||
} else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") {
|
} else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") {
|
||||||
prop.kind = "init";
|
prop.kind = "init";
|
||||||
if (isPattern) {
|
if (isPattern) {
|
||||||
|
if (this.isKeyword(prop.key.name) ||
|
||||||
|
(this.strict && (isStrictBadIdWord(prop.key.name) || isStrictReservedWord(prop.key.name))) ||
|
||||||
|
(!this.options.allowReserved && this.isReservedWord(prop.key.name)))
|
||||||
|
this.raise(prop.key.start, "Binding " + prop.key.name);
|
||||||
prop.value = this.parseMaybeDefault(start, prop.key);
|
prop.value = this.parseMaybeDefault(start, prop.key);
|
||||||
} else if (this.type === tt.eq && refShorthandDefaultPos) {
|
} else if (this.type === tt.eq && refShorthandDefaultPos) {
|
||||||
if (!refShorthandDefaultPos.start)
|
if (!refShorthandDefaultPos.start)
|
||||||
|
|||||||
@ -15508,3 +15508,5 @@ testFail("'use strict'; [...eval] = arr", "Assigning to eval in strict mode (1:1
|
|||||||
testFail("'use strict'; ({eval = defValue} = obj)", "Assigning to eval in strict mode (1:16)", {ecmaVersion: 6});
|
testFail("'use strict'; ({eval = defValue} = obj)", "Assigning to eval in strict mode (1:16)", {ecmaVersion: 6});
|
||||||
|
|
||||||
testFail("[...eval] = arr", "Assigning to eval in strict mode (1:4)", {ecmaVersion: 6, sourceType: "module"});
|
testFail("[...eval] = arr", "Assigning to eval in strict mode (1:4)", {ecmaVersion: 6, sourceType: "module"});
|
||||||
|
|
||||||
|
testFail("function* y({yield}) {}", "Binding yield (1:13)", {ecmaVersion: 6});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user