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/go2go: Panic in type checker #42522

Open
kalexmills opened this issue Nov 11, 2020 · 3 comments
Open

cmd/go2go: Panic in type checker #42522

kalexmills opened this issue Nov 11, 2020 · 3 comments
Assignees
Milestone

Comments

@kalexmills
Copy link

@kalexmills kalexmills commented Nov 11, 2020

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

Whatever is deployed at go2goplay.golang.org as of 11/11/2020 1:21 PM CST.

Does this issue reproduce with the latest release?

Presumably... I only tried it at go2goplay.golang.org

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

go env Output
$ go env

What did you do?

I tried to make this example compile. I don't claim that it's valid syntax, but it causes a panic in the typechecker, so I figured I'd raise it in any case.

https://go2goplay.golang.org/p/rC4sofqXuA5

What did you expect to see?

A compiler error (I think the use of [S] at line 16 is wrong, but don't quote me).

What did you see instead?

panic: assertion failed [recovered]
	panic: assertion failed [recovered]
	panic: assertion failed

goroutine 1 [running]:
go/types.(*Checker).handleBailout(0xc000116280, 0xc0003e7be0)
	/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, 0xc000175d60)
	/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.assert(...)
	/usr/local/go-faketime/src/go/types/errors.go:19
go/types.(*Checker).call(0xc000116280, 0xc0000730c0, 0xc000178550, 0x6e90c0, 0xc000010f60, 0x0)
	/usr/local/go-faketime/src/go/types/call.go:188 +0x17cf
go/types.(*Checker).exprInternal(0xc000116280, 0xc0000730c0, 0x6e90c0, 0xc000010f60, 0x0, 0x0, 0x203000)
	/usr/local/go-faketime/src/go/types/expr.go:1349 +0x2b75
go/types.(*Checker).rawExpr(0xc000116280, 0xc0000730c0, 0x6e90c0, 0xc000010f60, 0x0, 0x0, 0x0)
	/usr/local/go-faketime/src/go/types/expr.go:1033 +0xc5
go/types.(*Checker).exprOrType(0xc000116280, 0xc0000730c0, 0x6e90c0, 0xc000010f60)
	/usr/local/go-faketime/src/go/types/expr.go:1748 +0x55
go/types.(*Checker).call(0xc000116280, 0xc0000730c0, 0xc000053860, 0x6e8bc0, 0xc000053860, 0x2511aba00)
	/usr/local/go-faketime/src/go/types/call.go:21 +0xbf
go/types.(*Checker).exprInternal(0xc000116280, 0xc0000730c0, 0x6e8bc0, 0xc000053860, 0x0, 0x0, 0x823bc0)
	/usr/local/go-faketime/src/go/types/expr.go:1600 +0x1dba
go/types.(*Checker).rawExpr(0xc000116280, 0xc0000730c0, 0x6e8bc0, 0xc000053860, 0x0, 0x0, 0x0)
	/usr/local/go-faketime/src/go/types/expr.go:1033 +0xc5
go/types.(*Checker).multiExpr(0xc000116280, 0xc0000730c0, 0x6e8bc0, 0xc000053860)
	/usr/local/go-faketime/src/go/types/expr.go:1723 +0x51
go/types.(*Checker).exprList(0xc000116280, 0xc00001c6e0, 0x1, 0x1, 0x0, 0x203000, 0x203000, 0x203000, 0xc00017a068)
	/usr/local/go-faketime/src/go/types/call.go:282 +0xb4
go/types.(*Checker).initVars(0xc000116280, 0xc00000e398, 0x1, 0x1, 0xc00001c6e0, 0x1, 0x1, 0xc4)
	/usr/local/go-faketime/src/go/types/assignments.go:216 +0x94
go/types.(*Checker).stmt(0xc000116280, 0x0, 0x6e9280, 0xc00000c860)
	/usr/local/go-faketime/src/go/types/stmt.go:455 +0x3438
go/types.(*Checker).stmtList(0xc000116280, 0x0, 0xc00001c6f0, 0x1, 0x1)
	/usr/local/go-faketime/src/go/types/stmt.go:125 +0xd1
go/types.(*Checker).funcBody(0xc000116280, 0xc000176840, 0xc00001a43c, 0x3, 0xc000176a20, 0xc000010f90, 0x0, 0x0)
	/usr/local/go-faketime/src/go/types/stmt.go:42 +0x257
go/types.(*Checker).funcDecl.func1()
	/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.(*Checker).Files(...)
	/usr/local/go-faketime/src/go/types/check.go:257
go/types.(*Config).Check(0xc0000729c0, 0xc00001a3e0, 0x4, 0xc000072280, 0xc00003dcb8, 0x1, 0x1, 0xc0000533b0, 0x0, 0x4b70cf, ...)
	/usr/local/go-faketime/src/go/types/api.go:392 +0x188
go/go2go.RewriteBuffer(0xc000070360, 0x7ffca3778dec, 0x1e, 0xc00013a000, 0x15e, 0x35e, 0x0, 0xc000010a80, 0xc000010a50, 0xc000010a20, ...)
	/usr/local/go-faketime/src/go/go2go/go2go.go:139 +0x257
main.translateFile(0xc000070360, 0x7ffca3778dec, 0x1e)
	/usr/local/go-faketime/src/cmd/go2go/translate.go:26 +0xa9
main.main()
	/usr/local/go-faketime/src/cmd/go2go/main.go:74 +0x309

Go build failed.
@griesemer
Copy link
Contributor

@griesemer griesemer commented Nov 11, 2020

This is a bug in the type-checker in the prototype; but it works with the most-up-to-date implementation in dev.typeparams:

$ go tool compile -G x.go
x.go:16:9: invalid operation: cannot index FT.Map (value of type func(_ FT, f func(T) S) S)

where x.go contains the linked program, and the compiler was built from the dev.typeparams branch (note that the compiler doesn't generate code - it just type-checks).

cc: @findleyr

@kalexmills
Copy link
Author

@kalexmills kalexmills commented Nov 11, 2020

@griesemer Ok cool! This issue can be closed as far as I'm concerned.

I'll check twice before submitting anything from the go2go playground again.

@griesemer
Copy link
Contributor

@griesemer griesemer commented Nov 11, 2020

Please keep reporting. We will double-check both implementations - and even if we don't update the prototype, we'll add problem cases as tests to dev.typeparams if they are not covered already by existing tests.

Also, I'll keep this open for now until we have verified that both the compiler and a future go/types behave as expected with respect to this problem case, and/or we have added a matching test case.

Thanks!

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
3 participants