Skip to content

Commit

Permalink
Avoid excessive parentheses when we have an && or || chain
Browse files Browse the repository at this point in the history
  • Loading branch information
xumingkuan committed Aug 18, 2023
1 parent 95669a8 commit 67cb09c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion TypeInjections/TypeInjections/YIL.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1652,7 +1652,12 @@ module YIL =
| EUnOpApply (op, e) -> this.unaryOperator op precedence (expr (this.unaryOperatorPrecedence op) e)
| EBinOpApply (op, e1, e2) ->
let resolvedOp = this.binaryOperatorResolve op
this.binaryOperator resolvedOp precedence (expr (this.binaryOperatorPrecedenceLeft resolvedOp) e1)
let leftPart =
match e1 with
| EBinOpApply (opL, _, _) when opL = op ->
(expr 1 e1) // avoid excessive parentheses when we have an && or || chain
| _ -> (expr (this.binaryOperatorPrecedenceLeft resolvedOp) e1)
this.binaryOperator resolvedOp precedence leftPart
(expr (this.binaryOperatorPrecedenceRight resolvedOp) e2)
| EAnonApply (f, es) -> (expr 11 f) + (exprs es)
| EMethodApply (r, m, ts, es, _) -> (receiver r) + m.name + (exprs es)
Expand Down

0 comments on commit 67cb09c

Please sign in to comment.