Skip to content

cmd/compile: odd escaping in error message #43762

Closed

Description

@rsc

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.

Activity

  1. added
    NeedsFixThe path to resolution is known, but the work has not been done.
    on Jan 18, 2021
  2. added this to the Go1.17 milestone on Jan 18, 2021
  3. cuonglm commented on Jan 19, 2021

    @cuonglm
    Member

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

  4. mdempsky commented on Jan 19, 2021

    @mdempsky
    Contributor

    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

  5. gopherbot commented on Jan 19, 2021

    @gopherbot
    Contributor

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

  6. added a commit that references this issue on Jan 19, 2021
    9423d50
  7. mdempsky commented on Jan 19, 2021

    @mdempsky
    Contributor

    This is fixed on dev.regabi.

  8. locked and limited conversation to collaborators on Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe 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