]> Cypherpunks.ru repositories - gostls13.git/commit
go/printer: fix invalid output for empty decls
authorMauri de Souza Meneguzzo <mauri870@gmail.com>
Tue, 17 Oct 2023 18:36:31 +0000 (18:36 +0000)
committerGopher Robot <gobot@golang.org>
Tue, 17 Oct 2023 18:53:17 +0000 (18:53 +0000)
commitff7986d67029992b6a388a3797c4024d9a4856da
tree91b5969f0b8c8838ab4895ee2a37897cb4d3f905
parent860c2557ab7995e64e5cc0f045ff676f1fcec0a0
go/printer: fix invalid output for empty decls

The current output for empty declarations such as var, const, import
results in "var", "const", "import" respectively. These are not valid
and the parser will promptly reject them as invalid syntax.

This CL updates this behavior by adding "()" to the output of empty
decls so the syntax becomes valid, e.g "var ()" instead of "var".

Fixes #63566

Change-Id: I571b182d9ccf71b159360c8de003ad55d0ff3443
GitHub-Last-Rev: 2720419e364938e9962be71d0e6ed51375fec404
GitHub-Pull-Request: golang/go#63593
Reviewed-on: https://go-review.googlesource.com/c/go/+/535995
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Mauri de Souza Meneguzzo <mauri870@gmail.com>
src/go/printer/nodes.go
src/go/printer/printer_test.go