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: better error message syntax error in interface types #49205

Closed
komuw opened this issue Oct 28, 2021 · 5 comments
Closed

cmd/compile: better error message syntax error in interface types #49205

komuw opened this issue Oct 28, 2021 · 5 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@komuw
Copy link
Contributor

komuw commented Oct 28, 2021

What version of Go are you using (go version)?

$ go version
gotip version             
go version devel go1.18-a3bb28e5ff Thu Oct 28 14:25:03 2021 +0000 linux/amd64

Does this issue reproduce with the latest release?

N/A

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/homew/.cache/go-build"
GOENV="/home/homew/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/homew/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/homew/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/homew/sdk/gotip"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/homew/sdk/gotip/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.18-a3bb28e5ff Thu Oct 28 14:25:03 2021 +0000"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/homew/Downloads/cool/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/run/user/1000/go-build4161629763=/tmp/go-build -gno-record-gcc-switches"

What did you do?

mistakenly write;

package main

type A interface {
	int  int64
}
func main() { }

What did you expect to see?

main.go:60:7: syntax error: unexpected int64, expecting semicolon or newline or | or }

What did you see instead?

main.go:60:7: syntax error: unexpected int64, expecting semicolon or newline or }

ie, Now that interfaces can be used as type constraints; the error message should probably include | as one of the expected tokens.

@komuw komuw changed the title update interface been used as constraint error message. cmd/compile: update interface been used as constraint error message. Oct 28, 2021
@gopherbot
Copy link

Change https://golang.org/cl/359655 mentions this issue: cmd/compile: update error message for interface that used as constraint

@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 29, 2021
@dmitshur dmitshur added this to the Backlog milestone Oct 29, 2021
@mdempsky
Copy link
Member

mdempsky commented Nov 3, 2021

. and ( would also be valid tokens to appear after int. I'm not sure we need to be exhaustive in listing possible tokens.

@griesemer griesemer self-assigned this Nov 3, 2021
@griesemer griesemer modified the milestones: Backlog, Go1.18 Nov 9, 2021
@griesemer
Copy link
Contributor

Marking for 1.18 if we get to it, otherwise fine to delay to 1.19.

@griesemer
Copy link
Contributor

The error is reported by parser.list which doesn't have enough information for a better error yet. Either provide more context or leave away stating what is expected.

@gopherbot
Copy link

Change https://go.dev/cl/396914 mentions this issue: cmd/compile/internal/syntax: better errors for syntax errors in lists

@griesemer griesemer changed the title cmd/compile: update interface been used as constraint error message. cmd/compile: better error message syntax error in interface types Mar 30, 2022
@golang golang locked and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants