Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mateusz834 opened this issue Oct 12, 2024 · 3 comments
Assignees
Labels
Documentation Issues describing a change to documentation. NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@mateusz834
Copy link
Member

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.

@mateusz834 mateusz834 added Documentation Issues describing a change to documentation. NeedsFix The path to resolution is known, but the work has not been done. labels Oct 12, 2024
@mateusz834 mateusz834 self-assigned this Oct 12, 2024
@gabyhelp
Copy link

Related Issues and Documentation

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

@mateusz834
Copy link
Member Author

CC @griesemer @adonovan

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/619835 mentions this issue: go/ast: document invalid raw string literal end position containing carriage returns

@dmitshur dmitshur added this to the Go1.24 milestone Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Issues describing a change to documentation. NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants