On Mon, Aug 10, 2020 at 7:08 AM Alvadron <kloste...@gmail.com> wrote: > > The type of map keys in Go should be comparable. As you haven't specified any > restriction to the type parameters, it doesn't compile because Go doesn't > know whether K and V are comparable. > > If you add the restriction "comparable", then it compiles: > > type BiMap[type V, K comparable] struct { > forward map[K]V > reverse map[V]K > } > > PD: It is true that the error could be more informative. Right now we get: > > type checking failed for main > prog.go2:13:14: invalid map key type K > prog.go2:14:14: invalid map key type V > > Not sure if it is possible but, ideally, the message should say something > like "Invalid mp key type K: it is not comparable"
Getting a better error message is https://golang.org/issue/40551. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcU7ALYaKyh39xPUR-nurv_OFWxKhuwPSPThhZT5e1n6BA%40mail.gmail.com.