From e2e0e551dd8ec72b2691672baf07d7e44bd622bc Mon Sep 17 00:00:00 2001 From: Mateusz Poliwczak Date: Thu, 22 Aug 2024 14:12:51 +0200 Subject: [PATCH] go/ast: note that in BasicLit CHARs and STRINGs are quoted This reapplies CL 244960, for some reason CL 264181 removed this comment. Updates #39590 --- src/go/ast/ast.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/go/ast/ast.go b/src/go/ast/ast.go index 73aa3da89e..3844686503 100644 --- a/src/go/ast/ast.go +++ b/src/go/ast/ast.go @@ -299,6 +299,12 @@ type ( } // A BasicLit node represents a literal of basic type. + // + // Note that for the CHAR and STRING kinds, the literal is stored + // with its quotes. For example, for a double-quoted STRING, the + // first and the last rune in the Value field will be ". The + // Unquote and UnquoteChar functions in the strconv package can be + // used to unquote STRING and CHAR values, respectively. BasicLit struct { ValuePos token.Pos // literal position Kind token.Token // token.INT, token.FLOAT, token.IMAG, token.CHAR, or token.STRING