diff --git a/ecmascript/parser/Cargo.toml b/ecmascript/parser/Cargo.toml index 26bc040adb4e..ebfe6939cefe 100644 --- a/ecmascript/parser/Cargo.toml +++ b/ecmascript/parser/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "swc_ecma_parser" -version = "0.18.0" +version = "0.18.1" authors = ["강동윤 "] license = "Apache-2.0/MIT" repository = "https://github.com/swc-project/swc.git" diff --git a/ecmascript/parser/src/parser/stmt.rs b/ecmascript/parser/src/parser/stmt.rs index cb002727ea13..028de47cbfdc 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/tests/projects.rs b/tests/projects.rs index ee92b13372f6..d25d8a0a65d3 100644 --- a/tests/projects.rs +++ b/tests/projects.rs @@ -352,3 +352,12 @@ fn issue_605() { assert!(f.contains("Object.keys(_c)")); } + +#[test] +fn await_expr() { + let f = file("tests/projects/await-expression/input.js").unwrap(); + println!("{}", f); + + assert!(f.contains("await")); + assert!(f.contains("test")); +} diff --git a/tests/projects/await-expression/.swcrc b/tests/projects/await-expression/.swcrc new file mode 100644 index 000000000000..feb0370102fd --- /dev/null +++ b/tests/projects/await-expression/.swcrc @@ -0,0 +1,9 @@ +{ + "jsc": { + "target": "es2017", + "parser": { + "syntax": "ecmascript", + "topLevelAwait": true + } + } +} \ No newline at end of file diff --git a/tests/projects/await-expression/input.js b/tests/projects/await-expression/input.js new file mode 100644 index 000000000000..cf8aff5ca59c --- /dev/null +++ b/tests/projects/await-expression/input.js @@ -0,0 +1 @@ +await test ;