Files
liuxingbaoyuandGitHub 5b9e724df1 Add allowYieldOutsideFunction to parser (#17149)
* allowYieldOutsideFunction

* dts

* review

* template

* Revert "template"

This reverts commit 324e0893f51b5c8dd2c9f546e0cd3cc4441c5b56.

* improve error

* review
2025-03-21 11:19:58 +01:00

98 lines
4.1 KiB
JSON

{
"type": "File",
"start":0,"end":90,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":8,"column":1,"index":90}},
"errors": [
"SyntaxError: 'yield' is only allowed within generator functions. (5:6)"
],
"program": {
"type": "Program",
"start":0,"end":90,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":8,"column":1,"index":90}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "FunctionDeclaration",
"start":0,"end":90,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":8,"column":1,"index":90}},
"id": {
"type": "Identifier",
"start":10,"end":13,"loc":{"start":{"line":1,"column":10,"index":10},"end":{"line":1,"column":13,"index":13},"identifierName":"foo"},
"name": "foo"
},
"generator": true,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start":16,"end":90,"loc":{"start":{"line":1,"column":16,"index":16},"end":{"line":8,"column":1,"index":90}},
"body": [
{
"type": "ClassDeclaration",
"start":20,"end":88,"loc":{"start":{"line":2,"column":2,"index":20},"end":{"line":7,"column":3,"index":88}},
"id": {
"type": "Identifier",
"start":26,"end":27,"loc":{"start":{"line":2,"column":8,"index":26},"end":{"line":2,"column":9,"index":27},"identifierName":"C"},
"name": "C"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start":28,"end":88,"loc":{"start":{"line":2,"column":10,"index":28},"end":{"line":7,"column":3,"index":88}},
"body": [
{
"type": "ClassMethod",
"start":34,"end":49,"loc":{"start":{"line":3,"column":4,"index":34},"end":{"line":3,"column":19,"index":49}},
"static": true,
"key": {
"type": "Identifier",
"start":41,"end":44,"loc":{"start":{"line":3,"column":11,"index":41},"end":{"line":3,"column":14,"index":44},"identifierName":"foo"},
"name": "foo"
},
"computed": false,
"kind": "method",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start":47,"end":49,"loc":{"start":{"line":3,"column":17,"index":47},"end":{"line":3,"column":19,"index":49}},
"body": [],
"directives": []
}
},
{
"type": "StaticBlock",
"start":54,"end":84,"loc":{"start":{"line":4,"column":4,"index":54},"end":{"line":6,"column":5,"index":84}},
"body": [
{
"type": "ExpressionStatement",
"start":69,"end":78,"loc":{"start":{"line":5,"column":6,"index":69},"end":{"line":5,"column":15,"index":78}},
"expression": {
"type": "YieldExpression",
"start":69,"end":77,"loc":{"start":{"line":5,"column":6,"index":69},"end":{"line":5,"column":14,"index":77}},
"delegate": false,
"argument": {
"type": "NumericLiteral",
"start":75,"end":77,"loc":{"start":{"line":5,"column":12,"index":75},"end":{"line":5,"column":14,"index":77}},
"extra": {
"rawValue": 42,
"raw": "42"
},
"value": 42
}
}
}
]
}
]
}
}
],
"directives": []
}
}
],
"directives": []
}
}