Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

Commit

Permalink
Fixing test faiure for new # syntax
Browse files Browse the repository at this point in the history
Restricting PrivateName to be IdentifierName
  • Loading branch information
Diego committed Jan 9, 2017
1 parent 1af6425 commit beef2ef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/parser/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ pp.parseMaybeAssign = function (noIn, refShorthandDefaultPos, afterLeftParse, re
return this.finishNode(node, "AssignmentExpression");
} else if (failOnShorthandAssign && refShorthandDefaultPos.start) {
this.unexpected(refShorthandDefaultPos.start);
} else if (this.match(tt.hash)) {
this.raise(this.state.pos - 1, `Unexpected character '${tt.hash.label}'`);
}

return left;
Expand Down Expand Up @@ -287,7 +289,7 @@ pp.parseSubscripts = function (base, startPos, startLoc, noCalls) {
} else if (this.eat(tt.dot)) {
let node = this.startNodeAt(startPos, startLoc);
node.object = base;
node.property = hasClassPrivateProps ? this.parsePrivateName(true) : this.parseIdentifier(true);
node.property = hasClassPrivateProps ? this.parsePrivateName() : this.parseIdentifier(true);
node.computed = false;
base = this.finishNode(node, "MemberExpression");
} else if (this.eat(tt.bracketL)) {
Expand Down Expand Up @@ -500,7 +502,7 @@ pp.parseExprAtom = function (refShorthandDefaultPos) {

case tt.hash:
if (this.hasPlugin("classPrivateProperties")) {
return this.parsePrivateName(true);
return this.parsePrivateName();
} else {
this.unexpected(null, tt.hash);
}
Expand Down Expand Up @@ -1022,9 +1024,9 @@ pp.parseIdentifier = function (liberal) {
return this.finishNode(node, "Identifier");
};

pp.parsePrivateName = function (liberal) {
pp.parsePrivateName = function () {
const isPrivate = this.eat(tt.hash);
const node = this.parseIdentifier(liberal);
const node = this.parseIdentifier(true);
if (isPrivate) {
node.type = "PrivateName";
}
Expand Down
1 change: 1 addition & 0 deletions src/tokenizer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ export default class Tokenizer {
getTokenFromCode(code) {
switch (code) {
case 35: ++this.state.pos; return this.finishToken(tt.hash);

// The interpretation of a dot depends on whether it is followed
// by a digit or another two dots.
case 46: // '.'
Expand Down

0 comments on commit beef2ef

Please sign in to comment.