shapesecurity / shift-parser-js

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

`yield` nested in expressions fails to parse #264

Closed bakkot closed 8 years ago

bakkot commented 8 years ago
parseScript(`function *g() { 1+yield; }`, {earlyErrors:false});

fails with 'Unexpected token "yield"'. !yield and etc. in the generator body also fail, although 0, yield and [yield] do not.

Compare

parseScript(`function *g() { yield+1; }`, {earlyErrors:false});

which (correctly) succeeds.

bakkot commented 8 years ago

Never mind; this is correct. yield needs to be parenthesized in these contexts.