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/go: compiler crash on uncomparable map keys #28058

Closed
go101 opened this issue Oct 6, 2018 · 6 comments

Comments

Projects
None yet
6 participants
@go101
Copy link

commented Oct 6, 2018

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

go version go1.11.1 linux/amd64

Does this issue reproduce with the latest release?

yes

What did you do?

package main

var x map[func()]int

func main() {
}

What did you expect to see?

not crash

What did you see instead?

crash

# command-line-arguments
<autogenerated>:1: internal compiler error: unsupported map key type for map[func()]int

Please file a bug report including a short program that triggers the error.
https://golang.org/issue/new

@meirf meirf added the NeedsFix label Oct 7, 2018

@meirf meirf added this to the Go1.12 milestone Oct 7, 2018

@meirf

This comment has been minimized.

Copy link
Contributor

commented Oct 7, 2018

It looks like this also crashed in go1.10, but not in go1.9. Labeling as 1.12 since not a regression from 1.10.

/cc @griesemer

@mvdan

This comment has been minimized.

Copy link
Member

commented Oct 7, 2018

For reference, this is what Go 1.9.7 prints:

$ go build f.go
# command-line-arguments
./f.go:3:7: invalid map key type func()
@gopherbot

This comment has been minimized.

Copy link

commented Oct 7, 2018

Change https://golang.org/cl/140417 mentions this issue: cmd/compile: don't panic on invalid map key declarations

@odeke-em

This comment has been minimized.

Copy link
Member

commented Oct 7, 2018

Thanks for the report @go101 and @meirf @mvdan for the discernment.

I believe this was introduced by CL https://go-review.googlesource.com/61035 aka commit bb31217 which moved the order of those checks /cc @martisch @randall77

@mvdan

This comment has been minimized.

Copy link
Member

commented Oct 7, 2018

I don't think bb31217 is to blame, since I tried reverting that commit and the panic was still there. I think the bug is in the typechecker - see my CL above.

@odeke-em

This comment has been minimized.

Copy link
Member

commented Oct 10, 2018

Thanks for the correction and investigation @mvdan!

@gopherbot gopherbot closed this in 7f33131 Oct 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.