Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Object Getter triggers yield to incorrectly parse as YieldExpression #1982
Comments
|
I think I had a problem originally with my expected and actual json blocks. I have corrected this block to correctly match what I was expecting. |
When any get property is encountered the
context.allowYieldproperty is set to false and not reverted after parsing the getter body. This results in any future yield to be parsed as a yield expression incorrectly.Expected output
{ "type": "Program", "sourceType": "script", "body": [ { "type": "ExpressionStatement", "expression": { "type": "ObjectExpression", "properties": [ { "type": "Property", "key": { "type": "Identifier", "name": "a" }, "computed": false, "kind": "get", "method": false, "shorthand": false, "value": { "type": "FunctionExpression", "id": null, "params": [], "body": { "type": "BlockStatement", "body": [] }, "generator": false, "async": false, "expression": false } } ] } }, { "type": "ExpressionStatement", "expression": { "type": "Identifier", "name": "yield" } } ] }Actual output
{ "type": "Program", "body": [ { "type": "ExpressionStatement", "expression": { "type": "ObjectExpression", "properties": [ { "type": "Property", "key": { "type": "Identifier", "name": "a" }, "computed": false, "value": { "type": "FunctionExpression", "id": null, "params": [], "body": { "type": "BlockStatement", "body": [] }, "generator": false, "expression": false, "async": false }, "kind": "get", "method": false, "shorthand": false } ] } }, { "type": "ExpressionStatement", "expression": { "type": "YieldExpression", "argument": null, "delegate": false } } ], "sourceType": "script" }This is pulled directly from everything.js
Using this file as and example, I was surprised that removing line 84 will cause this to parse differently as they are completely unrelated.
I believe the offending code is located on line 3257 of parser.ts.
I believe the correct path in the ecma262 spec for line 200 would be