From: Rebecca Stambler Date: Tue, 17 Nov 2020 23:28:38 +0000 (-0500) Subject: go/ast: document invalid comment end positions with CRLF line endings X-Git-Tag: go1.16beta1~215 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a14e7bf6d42d9a8b0d698c0a47422c12e38b3f6c;p=gostls13.git go/ast: document invalid comment end positions with CRLF line endings 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 Run-TryBot: Rebecca Stambler Reviewed-by: Robert Griesemer --- diff --git a/src/go/ast/ast.go b/src/go/ast/ast.go index 1061f1d3ce..300966a326 100644 --- a/src/go/ast/ast.go +++ b/src/go/ast/ast.go @@ -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)