Skip to content

Commit

Permalink
fix(es/transforms/base): Fix await expressions. (#2157)
Browse files Browse the repository at this point in the history
swc_ecma_transforms_base:
 - Preserve parenthesis in `await (a || b)`. (#2155)
  • Loading branch information
kdy1 committed Aug 26, 2021
1 parent 18e2232 commit 8c5daee
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ecmascript/transforms/base/Cargo.toml
Expand Up @@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_transforms_base"
repository = "https://github.com/swc-project/swc.git"
version = "0.27.0"
version = "0.27.1"

[dependencies]
fxhash = "0.2.1"
Expand Down
16 changes: 15 additions & 1 deletion ecmascript/transforms/base/src/fixer.rs
Expand Up @@ -117,7 +117,11 @@ impl VisitMut for Fixer<'_> {
self.ctx = old;

match &*expr.arg {
Expr::Cond(..) | Expr::Assign(..) => self.wrap(&mut expr.arg),
Expr::Cond(..)
| Expr::Assign(..)
| Expr::Bin(..)
| Expr::Unary(..)
| Expr::Update(..) => self.wrap(&mut expr.arg),
_ => {}
}
}
Expand Down Expand Up @@ -1382,4 +1386,14 @@ var store = global[SHARED] || (global[SHARED] = {});
};
"
);

identical!(
issue_2155,
"
async function main() {
let promise;
await (promise || (promise = Promise.resolve('this is a string')));
}
"
);
}
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@swc/core",
"version": "1.2.82",
"version": "1.2.83",
"description": "Super-fast alternative for babel",
"homepage": "https://swc.rs",
"main": "./index.js",
Expand Down
2 changes: 1 addition & 1 deletion wasm/Cargo.toml
Expand Up @@ -6,7 +6,7 @@ license = "Apache-2.0 AND MIT"
name = "wasm"
publish = false
repository = "https://github.com/swc-project/swc.git"
version = "1.2.82"
version = "1.2.83"

[lib]
crate-type = ["cdylib"]
Expand Down

0 comments on commit 8c5daee

Please sign in to comment.