Skip to content

Commit

Permalink
Remove empty expression in expression statement with top level await (#…
Browse files Browse the repository at this point in the history
…630)

Eats the semi-colon.

This doesn't compile (edit: doesn't compile the code in the tests) 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!
  • Loading branch information
dsherret committed Feb 7, 2020
1 parent 26eb4e3 commit 55c0258
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ecmascript/parser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "swc_ecma_parser"
version = "0.18.0"
version = "0.18.1"
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
license = "Apache-2.0/MIT"
repository = "https://github.com/swc-project/swc.git"
Expand Down
1 change: 1 addition & 0 deletions ecmascript/parser/src/parser/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
Expand Down
9 changes: 9 additions & 0 deletions tests/projects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
9 changes: 9 additions & 0 deletions tests/projects/await-expression/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"jsc": {
"target": "es2017",
"parser": {
"syntax": "ecmascript",
"topLevelAwait": true
}
}
}
1 change: 1 addition & 0 deletions tests/projects/await-expression/input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
await test ;

0 comments on commit 55c0258

Please sign in to comment.