Ensure non pattern shorthand props are checked for reserved words (#479)
This commit is contained in:
parent
67db275c94
commit
7c56c24bb0
@ -884,8 +884,9 @@ pp.parseObjectProperty = function (prop, startPos, startLoc, isPattern, refShort
|
||||
}
|
||||
|
||||
if (!prop.computed && prop.key.type === "Identifier") {
|
||||
this.checkReservedWord(prop.key.name, prop.key.start, true, true);
|
||||
|
||||
if (isPattern) {
|
||||
this.checkReservedWord(prop.key.name, prop.key.start, true, true);
|
||||
prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key.__clone());
|
||||
} else if (this.match(tt.eq) && refShorthandDefaultPos) {
|
||||
if (!refShorthandDefaultPos.start) {
|
||||
|
||||
1
test/fixtures/es2015/shorthand/1/actual.js
vendored
Normal file
1
test/fixtures/es2015/shorthand/1/actual.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
var x = ({ const });
|
||||
3
test/fixtures/es2015/shorthand/1/options.json
vendored
Normal file
3
test/fixtures/es2015/shorthand/1/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "const is a reserved word (1:11)"
|
||||
}
|
||||
1
test/fixtures/es2015/shorthand/2/actual.js
vendored
Normal file
1
test/fixtures/es2015/shorthand/2/actual.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
({ get, this, if });
|
||||
3
test/fixtures/es2015/shorthand/2/options.json
vendored
Normal file
3
test/fixtures/es2015/shorthand/2/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "this is a reserved word (1:8)"
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user