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
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@rsc
Copy link
Contributor

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 The path to resolution is known, but the work has not been done. label Jan 18, 2021
@rsc rsc added this to the Go1.17 milestone Jan 18, 2021
@cuonglm
Copy link
Member

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 \\.

@mdempsky
Copy link
Member

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

@gopherbot
Copy link

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

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

This is fixed on dev.regabi.

@golang golang locked and limited conversation to collaborators Jan 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants