Skip to content

go/ast: (*ast.BasicLit).End() is wrong for raw literals with carriage returns ('\r') #69861

@mateusz834

Description

@mateusz834

Same as #41197, but for *ast.BasicLit can happen for raw literal strings.

As per the go spec:

Carriage return characters ('\r') inside raw string literals are discarded from the raw string value.

The End pos is calculated as such:

func (x *BasicLit) End() token.Pos { return token.Pos(int(x.ValuePos) + len(x.Value)) }

We are not storing the end pos in the *ast.BasicLit, so it might be not accurate for raw string literals containing carriage returns.

I think that same as in #41197, we should only document that.

Metadata

Metadata

Assignees

Labels

DocumentationIssues describing a change to documentation.NeedsFixThe path to resolution is known, but the work has not been done.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions