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
Closed

cmd/go: compiler crash on uncomparable map keys #28058

go101 opened this issue Oct 6, 2018 · 6 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@go101
Copy link

go101 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 The path to resolution is known, but the work has not been done. label Oct 7, 2018
@meirf meirf added this to the Go1.12 milestone Oct 7, 2018
@meirf
Copy link
Contributor

meirf 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
Copy link
Member

mvdan 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
Copy link

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

@odeke-em
Copy link
Member

odeke-em 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
Copy link
Member

mvdan 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
Copy link
Member

Thanks for the correction and investigation @mvdan!

@golang golang locked and limited conversation to collaborators Oct 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Projects
None yet
Development

No branches or pull requests

6 participants