From 71a4efbbdaeac569c6c3a593132e14436bd0b3d8 Mon Sep 17 00:00:00 2001 From: mappu Date: Sat, 11 Apr 2020 12:47:37 +1200 Subject: [PATCH] node: elide some more parens in assignment expressions --- node.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/node.go b/node.go index 3948e52..4b7920b 100644 --- a/node.go +++ b/node.go @@ -1541,7 +1541,7 @@ func (this *conversionState) convertAssignment(n *assign.Assign, isTopLevelState return "", parseErr{dimf, err} } - ret := arrayVar + ` = append(` + arrayVar + `, ` + rvalue + `)` + ret := arrayVar + ` = append(` + arrayVar + `, ` + removeParens(rvalue) + `)` if isTopLevelStatement { ret += "\n" } @@ -1559,6 +1559,7 @@ func (this *conversionState) convertAssignment(n *assign.Assign, isTopLevelState // TODO this may need to use `:=` if isTopLevelStatement { + rvalue = removeParens(rvalue) // safe in top-level assignment context // If this is a simple expression (func call; indirect/method call; assignment of func/method call) then // we need to propagate errors