Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Remove empty expression in expression statement with top level await #630

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ;