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/doc: Last comment used as example output might start too early #3139
Labels
Comments
The correct way of fixing this is to recognize that the comment starting at the end of the last statement and the comment // Output: ... belong to different comment groups. If the go/parser would recognize this, this issue would not come up. I don't believe this is a Go 1 show stopper. I will file a long-term issue against the go/parser instead. |
Labels changed: added priority-later, removed priority-triage. Status changed to Duplicate. Merged into issue #3142. |
This issue was closed by revision f26d617. Status changed to Fixed. |
griesemer
added a commit
that referenced
this issue
May 11, 2015
««« backport afbf8db1baf4 go/parser: fix comment grouping (day 1 bug) Comment groups must end at the end of a line (or the next non-comment token) if the group started on a line with non-comment tokens. This is important for correct computation of "lead" and "line" comments (Doc and Comment fields in AST nodes). Without this fix, the "line" comment for F1 in the following example: type T struct { F1 int // comment1 // comment2 F2 int } is "// comment1// comment2" rather than just "// comment1". This bug was present from Day 1 but only visible when looking at export-filtered ASTs where only comments associated with AST nodes are printed, and only in rare cases (e.g, in the case above, if F2 where not exported, godoc would show "// comment2" anyway because it was considered part of the "line" comment for F1). The bug fix is very small (parser.go). The bulk of the changes are additional test cases (parser_test.go). The fix exposed a caching bug in go/printer via one of the existing tests, hence the changes to printer.go. As an aside, the fix removes the the need for empty lines before an "// Output" comment for some special cases of code examples (e.g.: src/pkg/strings/example_test.go, Count example). No impact on gofmt formatting of src, misc. Fixes #3139. R=rsc CC=golang-dev https://golang.org/cl/6209080 »»»
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: