-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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/printer: comments were unexpected inserted in import
decl
#40546
Comments
import
declimport
decl
CC @griesemer |
Given that this breaks go-fuzz, does that increase the priority for 1.15 ? |
Just seeing this (I was on vacation last week). It's too late for 1.15. |
I think I can hardly say this is a bug in go/printer. For instance we have one comment at position n, and we inserted some statements without any position information just before n, it's hard to tell where should the comment be, in the middle of those inserted statements or after. One workaround useful to go-fuzz would be giving all inserted statements a position not accurate but less than the position of the subsequent comment. How this would work could be found at https://play.golang.org/p/KNEE2J4FrWt. |
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: