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
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Milestone

Comments

@rvolosatovs
Copy link

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

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 .

@ianlancetaylor ianlancetaylor added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 19, 2021
@ianlancetaylor ianlancetaylor added this to the Unreleased milestone Apr 19, 2021
@rvolosatovs
Copy link
Author

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.

@ianlancetaylor
Copy link
Contributor

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

@griesemer
Copy link
Contributor

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

@griesemer
Copy link
Contributor

@findleyr This program:

package main

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

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

@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 modified the milestones: Unreleased, Go1.17 Apr 19, 2021
@gopherbot
Copy link

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

@gopherbot
Copy link

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

@golang golang locked and limited conversation to collaborators Apr 20, 2022
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. release-blocker
Projects
None yet
Development

No branches or pull requests

5 participants