From 5a47c7a15c0f7e4377e30660672c8ceca6655c75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Wed, 18 Sep 2019 16:05:36 +0900 Subject: [PATCH] Fix `1 - (1 - 1)` (#418) --- ecmascript/transforms/src/fixer.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ecmascript/transforms/src/fixer.rs b/ecmascript/transforms/src/fixer.rs index 3bf3ff4b1a9..a09bc2c6936 100644 --- a/ecmascript/transforms/src/fixer.rs +++ b/ecmascript/transforms/src/fixer.rs @@ -353,7 +353,7 @@ impl Fold for Fixer { | e @ Expr::Cond(..) | e @ Expr::Arrow(..) => box e.wrap_with_paren(), Expr::Bin(BinExpr { op: op_of_rhs, .. }) => { - if op_of_rhs.precedence() < expr.op.precedence() { + if op_of_rhs.precedence() <= expr.op.precedence() { box expr.right.wrap_with_paren() } else { expr.right @@ -826,4 +826,6 @@ var store = global[SHARED] || (global[SHARED] = {}); "const myFilter = (arr, filter) => arr.filter(filter || ((x) => x));" ); + identical!(issue_418, "const a = 1 - (1 - 1)"); + }