shapesecurity / shift-parser-js

ECMAScript parser that produces a Shift format AST
http://shift-ast.org/parser.html
Apache License 2.0
251 stars 28 forks source link

Failure to parse AwaitExpression within Expression #411

Closed Protryon closed 5 years ago

Protryon commented 5 years ago

Example:

(async function() { (await y); })

Expected behavior: Successful parse

Actual behavior:

     Error: Not reached
      at ParserWithLocation.transformDestructuring (dist/parser.js:1398:13)
      at ParserWithLocation.transformDestructuringWithDefault (dist/parser.js:1410:19)
      at ParserWithLocation.parseGroupExpression (dist/parser.js:2125:71)
      at ParserWithLocation.parsePrimaryExpression (dist/parser.js:1909:21)
      at ParserWithLocation.parseLeftHandSideExpression (dist/parser.js:1752:21)
      at ParserWithLocation.parseUpdateExpression (dist/parser.js:1631:26)
      at ParserWithLocation.parseUnaryExpression (dist/parser.js:1603:21)
      at ParserWithLocation.parseExponentiationExpression (dist/parser.js:1574:23)
      at ParserWithLocation.parseBinaryExpression (dist/parser.js:1522:23)
      at ParserWithLocation.parseConditionalExpression (dist/parser.js:1469:23)
      at ParserWithLocation.parseAssignmentExpressionOrTarget (dist/parser.js:1248:23)
      at ParserWithLocation.isolateCoverGrammar (dist/parser.js:1148:23)
      at ParserWithLocation.parseAssignmentExpression (dist/parser.js:1236:19)
      at ParserWithLocation.parseExpression (dist/parser.js:1177:23)
      at ParserWithLocation.parseExpressionStatement (dist/parser.js:714:23)
      at ParserWithLocation.parseStatementHelper (dist/parser.js:643:23)
      at ParserWithLocation.isolateCoverGrammar (dist/parser.js:1148:23)
      at ParserWithLocation.parseStatement (dist/parser.js:627:23)
      at ParserWithLocation.parseStatementListItem (dist/parser.js:620:23)
      at ParserWithLocation.parseBody (dist/parser.js:326:61)
      at ParserWithLocation.parseFunctionBody (dist/parser.js:300:44)
      at ParserWithLocation.parseFunction (dist/parser.js:2640:23)
      at ParserWithLocation.parsePrimaryExpression (dist/parser.js:1917:39)
      at ParserWithLocation.parseLeftHandSideExpression (dist/parser.js:1691:21)
      at ParserWithLocation.parseUpdateExpression (dist/parser.js:1631:26)
      at ParserWithLocation.parseUnaryExpression (dist/parser.js:1603:21)
      at ParserWithLocation.parseExponentiationExpression (dist/parser.js:1574:23)
      at ParserWithLocation.parseBinaryExpression (dist/parser.js:1522:23)
      at ParserWithLocation.parseConditionalExpression (dist/parser.js:1469:23)
      at ParserWithLocation.parseAssignmentExpressionOrTarget (dist/parser.js:1248:23)
      at ParserWithLocation.inheritCoverGrammar (dist/parser.js:1166:23)
      at ParserWithLocation.parseGroupExpression (dist/parser.js:2123:24)
      at ParserWithLocation.parsePrimaryExpression (dist/parser.js:1909:21)
      at ParserWithLocation.parseLeftHandSideExpression (dist/parser.js:1752:21)
      at ParserWithLocation.parseUpdateExpression (dist/parser.js:1631:26)
      at ParserWithLocation.parseUnaryExpression (dist/parser.js:1603:21)
      at ParserWithLocation.parseExponentiationExpression (dist/parser.js:1574:23)
      at ParserWithLocation.parseBinaryExpression (dist/parser.js:1522:23)
      at ParserWithLocation.parseConditionalExpression (dist/parser.js:1469:23)
      at ParserWithLocation.parseAssignmentExpressionOrTarget (dist/parser.js:1248:23)
      at ParserWithLocation.isolateCoverGrammar (dist/parser.js:1148:23)
      at ParserWithLocation.parseAssignmentExpression (dist/parser.js:1236:19)
      at ParserWithLocation.parseExpression (dist/parser.js:1177:23)
      at ParserWithLocation.parseExpressionStatement (dist/parser.js:714:23)
      at ParserWithLocation.parseStatementHelper (dist/parser.js:643:23)
      at ParserWithLocation.isolateCoverGrammar (dist/parser.js:1148:23)
      at ParserWithLocation.parseStatement (dist/parser.js:627:23)
      at ParserWithLocation.parseStatementListItem (dist/parser.js:620:23)
      at ParserWithLocation.parseBody (dist/parser.js:326:61)
      at ParserWithLocation.parseScript (dist/parser.js:280:30)
      at parse (dist/index.js:191:16)
      at Context.<anonymous> (test/assertions.js:40:31)