node: elide some more parens in assignment expressions

This commit is contained in:
mappu 2020-04-11 12:47:37 +12:00
parent 5105293ce6
commit 71a4efbbda
1 changed files with 2 additions and 1 deletions

View File

@ -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