-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
cmd/cover: mishandles go: comments #10378
Comments
Infeasible. We need a way to manage comments in the AST. The current API of go/ast does not provide the hooks. |
Let's keep it open with milestone Unplanned. This renders coverage unusable for important use cases. |
I have to patch my syscall package to use coverage. |
@griesemer Robert, isn't it go/printer bug? The comments are attached to function declaration, why it inserts comments in the middle of other statements? |
@dvyukov Some comments are attached, some are not. In general, the AST support for comments is not ideal. Comments inside functions are not attached at all. There's complex code in the printer that merges comments and code by comparing position information. I haven't looked at the specifics of this problem. A generally correct solution (for all comments) is very difficult with the current AST. Maintaining function (and general declaration comments) should be doable. There's also the ast.CommentMap which may work for this problem. The long-term solution is a new AST where all comments are attached to nodes. |
Running with current tip.
syscall/syscall_linux_amd64.go mistransformed from:
to:
Reproduce by running (on linux/amd64):
The text was updated successfully, but these errors were encountered: