]> Cypherpunks repositories - gostls13.git/commitdiff
go/ast: document invalid raw string literal end position containing carriage returns
authorMateusz Poliwczak <mpoliwczak34@gmail.com>
Sat, 12 Oct 2024 17:34:52 +0000 (17:34 +0000)
committerGopher Robot <gobot@golang.org>
Sat, 19 Oct 2024 03:06:22 +0000 (03:06 +0000)
Fixes #69861

Change-Id: Id1684ee7d0c04262119d9e61f914bb9ecc0ef438
GitHub-Last-Rev: 5ad182c51aeb8b26631c6a97a7e9a2d89405ec06
GitHub-Pull-Request: golang/go#69862
Reviewed-on: https://go-review.googlesource.com/c/go/+/619835
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
src/go/ast/ast.go

index 5291c0a93a58c612d3382982d74d84f873ac937b..8d95eb12a95df6d0a70d81fbdb394e6c87971891 100644 (file)
@@ -305,6 +305,12 @@ type (
        // first and the last rune in the Value field will be ". The
        // [strconv.Unquote] and [strconv.UnquoteChar] functions can be
        // used to unquote STRING and CHAR values, respectively.
+       //
+       // For raw string literals (Kind == token.STRING && Value[0] == '`'),
+       // the Value field contains the string text without carriage returns (\r) that
+       // may have been present in the source. Because the end position is
+       // computed using len(Value), the position reported by [BasicLit.End] does not match the
+       // true source end position for raw string literals containing carriage returns.
        BasicLit struct {
                ValuePos token.Pos   // literal position
                Kind     token.Token // token.INT, token.FLOAT, token.IMAG, token.CHAR, or token.STRING