Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
'yield' parsed as keyword instead of identifier #1918
In the file src/scanner.ts, in the function isKeyword, yield is treated as a keyword, which is incorrect. This should be handled by the function nextToken() in src/parser.ts, where there already exists an appropriate test for strictness and reserved words in strict mode.
Steps to reproduce
esprima.parseScript('yield : 1')
Valid syntax tree.
Error: Line 1: Unexpected token :
https://www.ecma-international.org/ecma-262/8.0/index.html#sec-strict-mode-of-ecmascript states that yield is a keyword only in strict mode.