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

dev.go2go: assertion fails when type parameter is specified for non-generic function call #42319

tdakkota opened this issue Nov 1, 2020 · 1 comment


Copy link

@tdakkota tdakkota commented Nov 1, 2020

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

$ go version
go version devel +2298dab082 Thu Oct 22 00:19:08 2020 +0000 windows/amd64

Does this issue reproduce with the latest release?


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

  • go2go playground
  • windows/amd64

What did you do?

What did you expect to see?

An error like 'function A is not generic'.

What did you see instead?

Panic due to failed assertion.

Stack trace
panic: assertion failed [recovered]
	panic: assertion failed [recovered]
	panic: assertion failed

goroutine 1 [running]:
go/types.(*Checker).handleBailout(0xc000116280, 0xc000143be0)
	/usr/local/go-faketime/src/go/types/check.go:252 +0x9b
panic(0x64e940, 0x6e0db0)
	/usr/local/go-faketime/src/runtime/panic.go:969 +0x175
go/types.(*Checker).stmt.func1(0xc000116280, 0xc000055720)
	/usr/local/go-faketime/src/go/types/stmt.go:307 +0x85
panic(0x64e940, 0x6e0db0)
	/usr/local/go-faketime/src/runtime/panic.go:975 +0x3e9
go/types.(*Checker).call(0xc000116280, 0xc000072300, 0xc0000557c0, 0x6e90c0, 0xc000010c90, 0x0)
	/usr/local/go-faketime/src/go/types/call.go:188 +0x17cf
go/types.(*Checker).exprInternal(0xc000116280, 0xc000072300, 0x6e90c0, 0xc000010c90, 0x0, 0x0, 0x0)
	/usr/local/go-faketime/src/go/types/expr.go:1349 +0x2b75
go/types.(*Checker).rawExpr(0xc000116280, 0xc000072300, 0x6e90c0, 0xc000010c90, 0x0, 0x0, 0x0)
	/usr/local/go-faketime/src/go/types/expr.go:1033 +0xc5
go/types.(*Checker).exprOrType(0xc000116280, 0xc000072300, 0x6e90c0, 0xc000010c90)
	/usr/local/go-faketime/src/go/types/expr.go:1748 +0x55
go/types.(*Checker).call(0xc000116280, 0xc000072300, 0xc000055450, 0x6e8bc0, 0xc000055450, 0x0)
	/usr/local/go-faketime/src/go/types/call.go:21 +0xbf
go/types.(*Checker).exprInternal(0xc000116280, 0xc000072300, 0x6e8bc0, 0xc000055450, 0x0, 0x0, 0x38)
	/usr/local/go-faketime/src/go/types/expr.go:1600 +0x1dba
go/types.(*Checker).rawExpr(0xc000116280, 0xc000072300, 0x6e8bc0, 0xc000055450, 0x0, 0x0, 0x0)
	/usr/local/go-faketime/src/go/types/expr.go:1033 +0xc5
go/types.(*Checker).stmt(0xc000116280, 0x0, 0x6e8e00, 0xc00001c540)
	/usr/local/go-faketime/src/go/types/stmt.go:333 +0x3e9b
go/types.(*Checker).stmtList(0xc000116280, 0x0, 0xc00001c550, 0x1, 0x1)
	/usr/local/go-faketime/src/go/types/stmt.go:125 +0xd1
go/types.(*Checker).funcBody(0xc000116280, 0xc00004a540, 0xc00001a3ec, 0x4, 0xc00004a600, 0xc000010cc0, 0x0, 0x0)
	/usr/local/go-faketime/src/go/types/stmt.go:42 +0x257
	/usr/local/go-faketime/src/go/types/decl.go:813 +0x67
go/types.(*Checker).processDelayed(0xc000116280, 0x0)
	/usr/local/go-faketime/src/go/types/check.go:327 +0x3e
go/types.(*Checker).checkFiles(0xc000116280, 0xc00003dcb8, 0x1, 0x1, 0x0, 0x0)
	/usr/local/go-faketime/src/go/types/check.go:295 +0x205
go/types.(*Config).Check(0xc0000722c0, 0xc00001a3e0, 0x4, 0xc000072280, 0xc00003dcb8, 0x1, 0x1, 0xc0000553b0, 0x0, 0x4b70cf, ...)
	/usr/local/go-faketime/src/go/types/api.go:392 +0x188
go/go2go.RewriteBuffer(0xc00004a3c0, 0x7ffdc74c2dec, 0x1e, 0xc00013a000, 0x36, 0x236, 0x0, 0xc000010a80, 0xc000010a50, 0xc000010a20, ...)
	/usr/local/go-faketime/src/go/go2go/go2go.go:139 +0x257
main.translateFile(0xc00004a3c0, 0x7ffdc74c2dec, 0x1e)
	/usr/local/go-faketime/src/cmd/go2go/translate.go:26 +0xa9
	/usr/local/go-faketime/src/cmd/go2go/main.go:74 +0x309
Copy link

@griesemer griesemer commented Nov 5, 2020

This is fixed in cmd/compile/internal/types2, the version of go/types based on top of the compiler's internal syntax package (dev.go2go branch):

$ go test -run Check$ -files $HOME/tmp/x.go -errlist
--- FAIL: TestCheck (0.00s)
    check_test.go:116: /Users/gri/tmp/x.go:7:2: invalid operation: cannot index A (value of type func())

(with x.go containing the offending source per this report). This will need to be back-ported at some point.

As we are starting to focus on a real (non-prototype) implementation to explore a full implementation in the compiler, future fixes will be made in the dev.typeparams branch. We are not going to spend a lot of energy fixing minor errors in the dev.go2go branch.

Leaving open so that we can make sure this will be fixed in a future dev.typeparams go/types version.

cc: @findleyr

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

Successfully merging a pull request may close this issue.

None yet
3 participants