Skip to content

cmd/compile: compiler errors should quote user-provided names where they are used "in sentence" of an error message #65790

@seankhliao

Description

@seankhliao

Go version

go version devel go1.23-4a7f3ac8eb Sat Feb 10 02:14:22 2024 +0000 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/user/.cache/go-build'
GOENV='/home/user/.config/go/env'
GOEXE=''
GOEXPERIMENT='cacheprog'
GOFLAGS='-trimpath "-ldflags=-s -w"'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/user/.data/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/user/.data/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/user/sdk/gotip'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='path'
GOTOOLDIR='/home/user/sdk/gotip/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='devel go1.23-4a7f3ac8eb Sat Feb 10 02:14:22 2024 +0000'
GCCGO='gccgo'
GOAMD64='v3'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='0'
GOMOD='/home/user/tmp/testrepo0548/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2290460180=/tmp/go-build -gno-record-gcc-switches'

What did you do?

https://go.dev/play/p/cUZM3KyGHda

package main

import (
        "fmt"
)

func main() {
        int status
        fmt.Println(status)
}

What did you see happen?

# go.seankhliao.com/testrepo0548
./main.go:8:13: syntax error: unexpected status at end of statement

What did you expect to see?

"status" quoted as a user provided token, separating it from compiler status.

from #65788

cc @golang/compiler

Metadata

Metadata

Assignees

Labels

BadErrorMessageIssues related compiler error messages that should be better.FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions