golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
122.68k stars 17.49k forks source link

cmd/go2go: unhelpful error message with generic map key type #40551

Closed ianlancetaylor closed 4 years ago

ianlancetaylor commented 4 years ago

For this test case:

package p

type Set[type T] map[T]bool

var V Set[func()]

the type checker reports

foo.go2:3:22: invalid map key type T

This is accurate but cryptic. It would be better if the error message said something like map key type T does not have comparable constraint.

CC @griesemer

gopherbot commented 4 years ago

Change https://golang.org/cl/247258 mentions this issue: [dev.go2go] go/types: add special case report for generic map key type

griesemer commented 4 years ago

Fixed by https://golang.org/cl/247258.

gopherbot commented 4 years ago

Change https://golang.org/cl/248057 mentions this issue: [dev.go2go] cmd/compile/internal/types2: add special case report for generic map key type