mirror of
https://github.com/swc-project/swc.git
synced 2024-12-23 13:51:19 +03:00
Allow await expression at other than expression statement (#636)
Fixes #635
This commit is contained in:
parent
55c0258017
commit
add63826bd
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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"));
|
||||
}
|
||||
|
9
tests/projects/await-expression-2/.swcrc
Normal file
9
tests/projects/await-expression-2/.swcrc
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"jsc": {
|
||||
"target": "es2017",
|
||||
"parser": {
|
||||
"syntax": "ecmascript",
|
||||
"topLevelAwait": true
|
||||
}
|
||||
}
|
||||
}
|
1
tests/projects/await-expression-2/input.js
Normal file
1
tests/projects/await-expression-2/input.js
Normal file
@ -0,0 +1 @@
|
||||
const foo = await test;
|
Loading…
Reference in New Issue
Block a user