File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -290,7 +290,9 @@ func (v markerSubVisitor) Visit(node ast.Node) ast.Visitor {
290290 }
291291
292292 // skip comments on the same line as the previous node
293- if v .lastLineCommentGroup != nil && v .lastLineCommentGroup .Pos () == v .allComments [v .commentInd ].Pos () {
293+ // making sure to double-check for the case where we've gone past the end of the comments
294+ // but still have to finish up typespec-gendecl association (see below).
295+ if v .lastLineCommentGroup != nil && v .commentInd < len (v .allComments ) && v .lastLineCommentGroup .Pos () == v .allComments [v .commentInd ].Pos () {
294296 v .commentInd ++
295297 }
296298
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ var _ = BeforeSuite(func() {
5454 foo "fmt" // +testing:pkglvl="not here import 3"
5555
5656 // +testing:pkglvl="not here import 4"
57- )
57+ )
5858
5959 // +testing:pkglvl="here unattached"
6060
@@ -105,6 +105,15 @@ var _ = BeforeSuite(func() {
105105
106106 // +testing:typelvl="here on typedecl with no more"
107107 type Cheese struct { }
108+
109+ // ensure that we're fine if we've got an end-of-line
110+ // comment that's the last comment of the file, but
111+ // we still have a bit more to traverse (field list --> ident).
112+ // THIS MUST CONTAIN THE LAST COMMENT IN THE FILE
113+ // TODO(directxman12): split this off into its own case
114+ type private struct {
115+ bar int // not collected
116+ }
108117 ` ,
109118 },
110119 },
You can’t perform that action at this time.
0 commit comments