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

cmd/compile: odd escaping in error message #43762

Closed
rsc opened this issue Jan 18, 2021 · 4 comments
Closed

cmd/compile: odd escaping in error message #43762

rsc opened this issue Jan 18, 2021 · 4 comments
Labels
Milestone

Comments

@rsc
Copy link
Contributor

@rsc rsc commented Jan 18, 2021

https://play.golang.org/p/WX5BJVLjIkR

package main

func main() {
	_ = true == '\\'
}

produces

./prog.go:4:11: invalid operation: true == '\u005c' (mismatched types untyped bool and untyped rune)

It should almost certainly say '\\' not '\u005c'.
Took me a while to decode the first time I saw it.

@rsc rsc added the NeedsFix label Jan 18, 2021
@rsc rsc added this to the Go1.17 milestone Jan 18, 2021
@cuonglm
Copy link
Member

@cuonglm cuonglm commented Jan 19, 2021

Seems if we make it to print the rune literal, export will be broken https://codereview.appspot.com/5472046.

Although even without that special condition, we will say \, not \\.

Loading

@mdempsky
Copy link
Member

@mdempsky mdempsky commented Jan 19, 2021

I don't think export data should be affected by changing how fmt.go prints rune literals. fmt.go hasn't been involved in the export data format since the introduction of bexport.

We should certainly escape characters correctly though. Maybe we can just use %q for printing rune values less than 128: https://play.golang.org/p/MZ6CoEORrZN

Loading

@gopherbot
Copy link

@gopherbot gopherbot commented Jan 19, 2021

Change https://golang.org/cl/284592 mentions this issue: [dev.regabi] cmd/compile: use '%q' for printing rune values less than 128

Loading

gopherbot pushed a commit that referenced this issue Jan 19, 2021
… 128

Fixes #43762

Change-Id: I51734c9b4ee2366a5dae53b2d27b363f4d5fe6c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/284592
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
@mdempsky
Copy link
Member

@mdempsky mdempsky commented Jan 19, 2021

This is fixed on dev.regabi.

Loading

@mdempsky mdempsky closed this Jan 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants