Allow await expression at other than expression statement (#636)

Fixes #635
This commit is contained in:
kdy1 2020-02-08 01:49:00 +00:00
parent 55c0258017
commit add63826bd
4 changed files with 20 additions and 1 deletions

View File

@ -305,7 +305,7 @@ impl<'a, I: Tokens> Parser<'a, I> {
})));
}
if self.ctx().in_async && is!("await") {
if (self.ctx().in_async || self.syntax().top_level_await()) && is!("await") {
return self.parse_await_expr();
}

View File

@ -361,3 +361,12 @@ fn await_expr() {
assert!(f.contains("await"));
assert!(f.contains("test"));
}
#[test]
fn await_expr_2() {
let f = file("tests/projects/await-expression-2/input.js").unwrap();
println!("{}", f);
assert!(f.contains("await"));
assert!(f.contains("test"));
}

View File

@ -0,0 +1,9 @@
{
"jsc": {
"target": "es2017",
"parser": {
"syntax": "ecmascript",
"topLevelAwait": true
}
}
}

View File

@ -0,0 +1 @@
const foo = await test;