New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
go/format: formatting an empty var decl produces invalid syntax #63566
Comments
cagedmantis
added
the
NeedsFix
The path to resolution is known, but the work has not been done.
label
Oct 16, 2023
@adonovan I noticed the same happens with token.CONST and token.IMPORT, should these follow the same convention you suggested for var? |
Yes, the logic is probably common to all of them. |
mauri870
added a commit
to mauri870/go
that referenced
this issue
Oct 17, 2023
The current output for empty declarations such as var, const, import results in "var", "const", "import" respectively. These are not valid syntax 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 golang#63566
Change https://go.dev/cl/535995 mentions this issue: |
yunginnanet
pushed a commit
to yunginnanet/go
that referenced
this issue
Oct 20, 2023
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 golang#63566 Change-Id: I571b182d9ccf71b159360c8de003ad55d0ff3443 GitHub-Last-Rev: 2720419 GitHub-Pull-Request: golang#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>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When the formatter is given a var decl with no specs, it produces the output
"var"
, which cannot be parsed as a decl:The output should be
var ()
.The text was updated successfully, but these errors were encountered: