From d06eeed35204e113ffa9f9e800a41957cdf06bad Mon Sep 17 00:00:00 2001 From: kdy1 Date: Wed, 29 Jan 2020 02:59:25 +0000 Subject: [PATCH] Async generator (#613) Change parser to accept async generator. Closes #612. --- ecmascript/parser/src/parser/class_and_fn.rs | 6 +-- .../custom/issue-612-async-generator/issue.js | 1 + .../issue-612-async-generator/issue.js.json | 46 +++++++++++++++++++ .../custom/issue-612-async-generator/input.ts | 1 + .../issue-612-async-generator/input.ts.json | 46 +++++++++++++++++++ 5 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 ecmascript/parser/tests/jsx/basic/custom/issue-612-async-generator/issue.js create mode 100644 ecmascript/parser/tests/jsx/basic/custom/issue-612-async-generator/issue.js.json create mode 100644 ecmascript/parser/tests/typescript/custom/issue-612-async-generator/input.ts create mode 100644 ecmascript/parser/tests/typescript/custom/issue-612-async-generator/input.ts.json diff --git a/ecmascript/parser/src/parser/class_and_fn.rs b/ecmascript/parser/src/parser/class_and_fn.rs index 30c66d0ec2f..392c5e8465a 100644 --- a/ecmascript/parser/src/parser/class_and_fn.rs +++ b/ecmascript/parser/src/parser/class_and_fn.rs @@ -760,9 +760,9 @@ impl<'a, I: Tokens> Parser<'a, I> { let is_generator = { let start = cur_pos!(); if eat!('*') { - if is_async { - syntax_error!(span!(start), SyntaxError::AsyncGenerator {}); - } + // if is_async { + // syntax_error!(span!(start), SyntaxError::AsyncGenerator {}); + // } true } else { false diff --git a/ecmascript/parser/tests/jsx/basic/custom/issue-612-async-generator/issue.js b/ecmascript/parser/tests/jsx/basic/custom/issue-612-async-generator/issue.js new file mode 100644 index 00000000000..40e8c61cf10 --- /dev/null +++ b/ecmascript/parser/tests/jsx/basic/custom/issue-612-async-generator/issue.js @@ -0,0 +1 @@ +async function* agf() {} \ No newline at end of file diff --git a/ecmascript/parser/tests/jsx/basic/custom/issue-612-async-generator/issue.js.json b/ecmascript/parser/tests/jsx/basic/custom/issue-612-async-generator/issue.js.json new file mode 100644 index 00000000000..c1e0ce105a3 --- /dev/null +++ b/ecmascript/parser/tests/jsx/basic/custom/issue-612-async-generator/issue.js.json @@ -0,0 +1,46 @@ +{ + "type": "Module", + "span": { + "start": 0, + "end": 24, + "ctxt": 0 + }, + "body": [ + { + "type": "FunctionDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 16, + "end": 19, + "ctxt": 0 + }, + "value": "agf", + "typeAnnotation": null, + "optional": false + }, + "declare": false, + "params": [], + "decorators": [], + "span": { + "start": 0, + "end": 24, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 22, + "end": 24, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": true, + "async": true, + "typeParameters": null, + "returnType": null + } + ], + "interpreter": null +} diff --git a/ecmascript/parser/tests/typescript/custom/issue-612-async-generator/input.ts b/ecmascript/parser/tests/typescript/custom/issue-612-async-generator/input.ts new file mode 100644 index 00000000000..40e8c61cf10 --- /dev/null +++ b/ecmascript/parser/tests/typescript/custom/issue-612-async-generator/input.ts @@ -0,0 +1 @@ +async function* agf() {} \ No newline at end of file diff --git a/ecmascript/parser/tests/typescript/custom/issue-612-async-generator/input.ts.json b/ecmascript/parser/tests/typescript/custom/issue-612-async-generator/input.ts.json new file mode 100644 index 00000000000..c1e0ce105a3 --- /dev/null +++ b/ecmascript/parser/tests/typescript/custom/issue-612-async-generator/input.ts.json @@ -0,0 +1,46 @@ +{ + "type": "Module", + "span": { + "start": 0, + "end": 24, + "ctxt": 0 + }, + "body": [ + { + "type": "FunctionDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 16, + "end": 19, + "ctxt": 0 + }, + "value": "agf", + "typeAnnotation": null, + "optional": false + }, + "declare": false, + "params": [], + "decorators": [], + "span": { + "start": 0, + "end": 24, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 22, + "end": 24, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": true, + "async": true, + "typeParameters": null, + "returnType": null + } + ], + "interpreter": null +}