-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Description
Go version
go version go1.24.0 darwin/amd64
Output of go env
in your module/workspace:
Playground
What did you do?
See: https://go.dev/play/p/cF220dL8yUT
Sometimes I use *ast.BasicLit
in my Code generators to write Go statements rather than properly breaking down the statement to the proper ast.*
components. It's just easier this way and has never caused me any issues.
Until I noticed this very specific bug:
&ast.BasicLit{
Kind: token.INT,
Value: "Error()",
}
gets rendered as:
error()
I understand this is not the proper way to parse and/or alter the syntax tree. This bug report is just regarding a weird inconsistency. Every other combination for Value:
works properly.
What did you see happen?
Improper rendering.
What did you expect to see?
I expected to see: Error()
In the Go playground you can change the stmt to ANYTHING else and it will render properly:
https://go.dev/play/p/cF220dL8yUT
https://go.dev/play/p/FuxSXer6I4g
(WORK-AROUND: When I change it to token.STRING
it works)