]> Cypherpunks repositories - gostls13.git/commitdiff
go/ast: document invalid comment end positions with CRLF line endings
authorRebecca Stambler <rstambler@golang.org>
Tue, 17 Nov 2020 23:28:38 +0000 (18:28 -0500)
committerRebecca Stambler <rstambler@golang.org>
Wed, 18 Nov 2020 06:29:09 +0000 (06:29 +0000)
We've decided that issues like golang/go#41197 are unfixable, so
instead, document the bug.

Fixes golang/go#41197

Change-Id: I5649027f6e2445eec765516f2f642db0d601ea20
Reviewed-on: https://go-review.googlesource.com/c/go/+/270938
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/go/ast/ast.go

index 1061f1d3cef92140b0a232ddd84916cc4c130d52..300966a32638009c3b8d44f84e297d116c6e37e5 100644 (file)
@@ -57,6 +57,11 @@ type Decl interface {
 // Comments
 
 // A Comment node represents a single //-style or /*-style comment.
+//
+// The Text field contains the comment text without carriage returns (\r) that
+// may have been present in the source. Because a comment's end position is
+// computed using len(Text), the position reported by End() does not match the
+// true source end position for comments containing carriage returns.
 type Comment struct {
        Slash token.Pos // position of "/" starting the comment
        Text  string    // comment text (excluding '\n' for //-style comments)