cmd/cgo: newline replacement in composite literals generates invalid code #67517
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsFix
The path to resolution is known, but the work has not been done.
Go version
go1.22.1 linux/amd64
Output of
go env
in your module/workspace:What did you do?
reproduction in godbolt since the playground does not allow cgo
What did you see happen?
What did you expect to see?
Parsing fails because semicolons are incorrectly inserted in the generated code:
This is because gofmtLineReplacer does not account for consecutive newlines.
While the reproduction is clearly non-problematic, I found the issue in a much more involved construction (VkGraphicsPipelineCreateInfo) in which the freedom to insert newlines and comments is incredibly beneficial.
Furthermore, it appears that perhaps the replacing is too heavy handed in general since it also applies to string literals.
Related: #29748, #31017, #29781
The text was updated successfully, but these errors were encountered: