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

Some semantics-preserving changes #397

Closed bakkot closed 6 years ago

bakkot commented 6 years ago

Split this out from the async-await work, since it makes sense in an ES2016 context as well.

One of these changes is actually a bugfix: currently class let {} is rejected by the parser, rather than the early error checker, which means that if you manually construct the following well-typed AST:

{
  type: 'Script',
  directives: [],
  statements: [
    {
      type: 'ClassDeclaration',
      name: { type: 'BindingIdentifier', name: 'let' },
      super: null,
      elements: []
    }
  ]
}

this will pass both the validator and the early error checker, which violates their collective contract.

(ditto for other strict-mode reserved words).

The change to parseArguments is unrelated, but necessary for other work (specifically async arrows), so I'd like it to at least run through CI. It shouldn't change anything.