From 9a21caa1371b48b33c2ee9b4a414eb0500a5a217 Mon Sep 17 00:00:00 2001 From: dsherret Date: Thu, 6 Feb 2020 04:14:41 +0000 Subject: [PATCH] Remove empty expression in expression statement with top level await (#630) Eats the semi-colon. This doesn't compile though because the target of that folder is ES2015. Also, this is kind of strange for me to put the tests in the "typescript" folder. Should we create something more general? You can take over this PR if you'd like! --- ecmascript/parser/src/parser/stmt.rs | 1 + .../typescript/await-expression/input.ts | 1 + .../typescript/await-expression/input.ts.json | 38 +++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 ecmascript/parser/tests/typescript/await-expression/input.ts create mode 100644 ecmascript/parser/tests/typescript/await-expression/input.ts.json diff --git a/ecmascript/parser/src/parser/stmt.rs b/ecmascript/parser/src/parser/stmt.rs index cb002727ea13c..028de47cbfdcb 100644 --- a/ecmascript/parser/src/parser/stmt.rs +++ b/ecmascript/parser/src/parser/stmt.rs @@ -100,6 +100,7 @@ impl<'a, I: Tokens> Parser<'a, I> { } let expr = self.parse_await_expr()?; + eat!(';'); let span = span!(start); return Ok(Stmt::Expr(ExprStmt { span, expr })); diff --git a/ecmascript/parser/tests/typescript/await-expression/input.ts b/ecmascript/parser/tests/typescript/await-expression/input.ts new file mode 100644 index 0000000000000..3b44babe1eb65 --- /dev/null +++ b/ecmascript/parser/tests/typescript/await-expression/input.ts @@ -0,0 +1 @@ +await test ; diff --git a/ecmascript/parser/tests/typescript/await-expression/input.ts.json b/ecmascript/parser/tests/typescript/await-expression/input.ts.json new file mode 100644 index 0000000000000..930324d29f90a --- /dev/null +++ b/ecmascript/parser/tests/typescript/await-expression/input.ts.json @@ -0,0 +1,38 @@ +{ + "type": "Module", + "span": { + "start": 0, + "end": 17, + "ctxt": 0 + }, + "body": [ + { + "type": "ExpressionStatement", + "span": { + "start": 0, + "end": 17, + "ctxt": 0 + }, + "expression": { + "type": "AwaitExpression", + "span": { + "start": 0, + "end": 13, + "ctxt": 0 + }, + "argument": { + "type": "Identifier", + "span": { + "start": 9, + "end": 13, + "ctxt": 0 + }, + "value": "test", + "typeAnnotation": null, + "optional": false + } + } + } + ], + "interpreter": null +}