Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
go/printer: never print a newline before the returned results
Otherwise, if one ends up with a "return result" where the two nodes are in separate lines, the printer would incorrectly print a naked return: return result The fix is simple - by not telling exprList what the previous position is, it never adds a leading linebreak. This is the same mechanism used for identifier lists and values, so it seems appropriate. All other exprList calls that can produce a leading linebreak don't seem buggy, because closing tokens such as parentheses and colons are needed to finish the statement. Verified that the test failed before the patch as well: --- FAIL: TestIssue32854 (0.00s) printer_test.go:806: got "return\n\tcall()", want "return call()" Finally, verified that 'gofmt -l -w src misc' doesn't make any new changes, just in case we introduced any regression. Fixes golang#32854. Change-Id: I3384fbd711de06e742407df874c9ad85626d5d6a Reviewed-on: https://go-review.googlesource.com/c/go/+/184121 Run-TryBot: Daniel Martí <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Robert Griesemer <[email protected]>
- Loading branch information