go/printer: comments were unexpected inserted in import
decl
#40546
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
https://play.golang.org/p/65fHR5rtBXR
What I'm trying to do here is inserting an
import
decl in the front of a simple go source file, and as shown, an unexpected comment appeared in the middle of the inserted import, which breaks the source file.What did you expect to see?
What did you see instead?
Buggy version and expected version (fixed with some ad-hoc logic) are both in the above link.
<del>
I believe what happened here is after remembering the offset of one comment at
go/src/go/printer/printer.go
Line 137 in 6f26480
commentBefore
go/src/go/printer/printer.go
Line 153 in 6f26480
</del>
I can draft a patch if I'm not misunderstanding about the root cause.
update: the guess above is incorrect, still investigating.
The text was updated successfully, but these errors were encountered: