-
Notifications
You must be signed in to change notification settings - Fork 18k
go/parser: comments to parameters are not processed #25814
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
Comments
Indeed, looks like a corner case. @griesemer |
Wait sorry, if I set the mode to func main() {
fset := token.NewFileSet()
f, err := parser.ParseFile(fset, "_", f, parser.ParseComments)
if err != nil {
ffmt.Mark(err)
return
}
ast.Print(fset, f)
} The comments are part of for _, v := range f.Comments {
ffmt.P(v)
} I am not sure whether an |
It only exists in File.Comments , not in ast.field |
Change https://golang.org/cl/117795 mentions this issue: |
@wzshiming Unfortunately this is by design (these comments are not shown in godoc, after all). I wouldn't call it "not reasonable", but I agree that it's unfortunate. Keep in mind that go/ast, go/parser, and friends are among the very first larger Go packages ever written and they show their age. Also, and I'm taking full responsibility for this, only doc comments are directly attached to AST nodes; all the other ones are collected in the File.Comments list and must be "interspersed" by position when printing. It works ok for gofmt but it's a real pain elsewhere. In retrospect that was a bad design decision. We know all about it. Closing as unfortunate. |
Comments to parameters are not processed here
go/src/go/parser/parser.go
Line 835 in b74f732
I think this comment should be processed
The text was updated successfully, but these errors were encountered: