Huáng Jùnliàng 108564fdad
refactor: raise AwaitNotInAsyncContext when an AwaitExpression will be parsed (#12716)
* refactor: raise AwaitNotInAsyncContext when an AwaitExpression will be parsed

* tweak logic

* early exit when errors are before thrown error position

* fix: always return true in assert.throws callback

See https://nodejs.org/api/assert.html#assert_assert_throws_fn_error_message

* update test fixtures

* fix flow error
2021-02-01 10:46:43 -05:00

63 lines
2.3 KiB
JSON

{
"type": "File",
"start":0,"end":24,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":24}},
"errors": [
"SyntaxError: Unexpected reserved word 'await' (1:8)"
],
"program": {
"type": "Program",
"start":0,"end":24,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":24}},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "VariableDeclaration",
"start":0,"end":24,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":24}},
"declarations": [
{
"type": "VariableDeclarator",
"start":6,"end":23,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":23}},
"id": {
"type": "ObjectPattern",
"start":6,"end":15,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":15}},
"properties": [
{
"type": "ObjectProperty",
"start":8,"end":13,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":13}},
"extra": {
"shorthand": true
},
"method": false,
"key": {
"type": "Identifier",
"start":8,"end":13,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":13},"identifierName":"await"},
"name": "await"
},
"computed": false,
"shorthand": true,
"value": {
"type": "Identifier",
"start":8,"end":13,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":13},"identifierName":"await"},
"name": "await"
}
}
]
},
"init": {
"type": "CallExpression",
"start":18,"end":23,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":23}},
"callee": {
"type": "Identifier",
"start":18,"end":21,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":21},"identifierName":"foo"},
"name": "foo"
},
"arguments": []
}
}
],
"kind": "const"
}
],
"directives": []
}
}