Skip to content

Commit

Permalink
Ensure non pattern shorthand props are checked for reserved words (ba…
Browse files Browse the repository at this point in the history
  • Loading branch information
existentialism authored and danez committed May 10, 2017
1 parent 67db275 commit 7c56c24
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/parser/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/es2015/shorthand/1/actual.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var x = ({ const });
3 changes: 3 additions & 0 deletions test/fixtures/es2015/shorthand/1/options.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"throws": "const is a reserved word (1:11)"
}
1 change: 1 addition & 0 deletions test/fixtures/es2015/shorthand/2/actual.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
({ get, this, if });
3 changes: 3 additions & 0 deletions test/fixtures/es2015/shorthand/2/options.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"throws": "this is a reserved word (1:8)"
}

0 comments on commit 7c56c24

Please sign in to comment.