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

go/types: missing error message for incorrect (generic) program #45635

Closed
rvolosatovs opened this issue Apr 19, 2021 · 7 comments
Closed

go/types: missing error message for incorrect (generic) program #45635

rvolosatovs opened this issue Apr 19, 2021 · 7 comments

Comments

@rvolosatovs
Copy link

@rvolosatovs rvolosatovs commented Apr 19, 2021

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

go version 2021-03-22 linux/amd64

Does this issue reproduce with the latest release?

yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN="/home/rvolosatovs/.local/bin.go"
GOCACHE="/home/rvolosatovs/.local/cache/go-build"
GOENV="/home/rvolosatovs/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/rvolosatovs/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/rvolosatovs"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/nix/store/jfzfymdd8pdia5jlvnc96nm5znjh9x6j-go2-unstable-2021-03-22/share/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/nix/store/jfzfymdd8pdia5jlvnc96nm5znjh9x6j-go2-unstable-2021-03-22/share/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="2021-03-22"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/rvolosatovs/src/github.com/rvolosatovs/collections/go.mod"
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-build2470782358=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Panics(two or more parameters): https://go2goplay.golang.org/p/gc3cZ-qe5bG

Works: https://go2goplay.golang.org/p/AQ_JWojgRic
Prints correct error(single parameter): https://go2goplay.golang.org/p/bW2i30OWP6F

What did you expect to see?

The first example should print an error same as last one

Note, that calls to identifiers defined in imported packages with multiple parameters fail with the same error

What did you see instead?

Panic in parser

@rvolosatovs rvolosatovs changed the title cmd/go2go: Panic on unresolved multi-paramgeneric calls to imported and unknown identifiers cmd/go2go: Panic on unresolved multi-parameter generic calls Apr 19, 2021
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Apr 19, 2021

This is a panic in the go2go type checker. The current type checker reports an error (undefined: some). I don't think it's worth updating the go2go type checker to better handle erroneous cases, but leaving for @griesemer .

Loading

@rvolosatovs
Copy link
Author

@rvolosatovs rvolosatovs commented Apr 19, 2021

Well

panic: prog.go2:4:7: unknown expression type *ast.ListExpr [recovered]
	panic: prog.go2:4:7: unknown expression type *ast.ListExp

is quite cryptic for the end user in my opinion, so I think it's definitely worth improving. Note, again, that it works fine with single parameter identifiers.

What's more important is that this seems to also break references to identifiers in different packages.
Locally, the go2go tool panics when instantiating multi-parameter imported types/functions.

Loading

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Apr 19, 2021

I don't see that error on tip. Which version of the program are you testing?

Loading

@griesemer
Copy link
Contributor

@griesemer griesemer commented Apr 19, 2021

@rvolosatovs This is working as expected on tip (types2, and compiler with -G=3 option). It doesn't produce any error message with go/types at the moment, and that seems like a bug. What you are seeing is likely due to running a version that is not fully up-to-date. The go2go playground will be updated eventually, but currently is a bit behind.

Loading

@griesemer
Copy link
Contributor

@griesemer griesemer commented Apr 19, 2021

@findleyr This program:

package main

func main() {
	some[int, int]()
}

doesn't seem to produce an error message with go/types at the moment.

Loading

@griesemer griesemer changed the title cmd/go2go: Panic on unresolved multi-parameter generic calls go/types: missing error message for incorrect (generic) program Apr 19, 2021
@griesemer griesemer removed this from the Unreleased milestone Apr 19, 2021
@griesemer griesemer added this to the Go1.17 milestone Apr 19, 2021
@gopherbot
Copy link

@gopherbot gopherbot commented Apr 19, 2021

Change https://golang.org/cl/311669 mentions this issue: go/types: fix panic when using multiple type arguments

Loading

@gopherbot gopherbot closed this in 9f87943 Apr 20, 2021
@gopherbot
Copy link

@gopherbot gopherbot commented Apr 20, 2021

Change https://golang.org/cl/312149 mentions this issue: go/types: add more guards against accidentally checking a ListExpr

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants