Skip to content

Commit

Permalink
fixed issue with optional chaining conflating decimal numbers in a
Browse files Browse the repository at this point in the history
ternary operator `true?.10:.20` would not work before
  • Loading branch information
bizob2828 committed Oct 26, 2020
1 parent 46c64c7 commit db12621
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,7 @@ export class Parser {
const quasi = this.parseTemplateLiteral();
expr = this.finalize(this.startNode(startToken), new Node.TaggedTemplateExpression(expr, quasi));
} else if (this.match('?.')) {
this.nextToken();
this.nextToken();
if (this.match('(')) {
var asyncArrow = maybeAsync && (startToken.lineNumber === this.lookahead.lineNumber);
this.context.isBindingElement = false;
Expand Down
3 changes: 2 additions & 1 deletion src/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,8 @@ export class Scanner {
break;
case '?':
++this.index;
if (this.source[this.index] === '.') {
// see https://github.com/tc39/proposal-optional-chaining#notes for why we have to check 2 lookaheads
if (this.source[this.index] === '.' && isNaN(Number(this.source[this.index +1]))) {
// optional chaining
this.index += 1;
str = '?.';
Expand Down

0 comments on commit db12621

Please sign in to comment.