On Wed, Jan 18, 2023 at 4:52 PM Andrew Athan <andrew...@gmail.com> wrote: > > (Possibly related to issues such as those discussed in > https://groups.google.com/g/golang-nuts/c/pO2sclKEoQs/m/5JYjveKgCQAJ ?) > > If I do: > > ``` > func Foo[V any](v V)bool { > return v==v > } > ``` > > golang 1.19 reports: > > ``` > invalid operation: v == v (incomparable types in type set) > ``` > > There are two issues with this in my mind: (1) It is ambiguous in that I > cannot be sure, as a new user, whether what's being indicated is an > incompatibility between the actual types on either side of the equality test > or between the set of possible types that COULD be on either side of the > equality test due to V's any type constraing in either the case where the > left and right side are same or different types (2) In this case, the type V > appears to be determinable at compile time and yet it is claimed this > equality test is in some way problematic. > > I'm sure I'm misunderstanding something about golang generics.
Start reading here: https://go.googlesource.com/proposal/+/refs/heads/master/design/43651-type-parameters.md#operators 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/CAOyqgcXsT4A2nhDmUyEkJdzib%2Bh4BgOaKwrgLSBX21FNh1b4kA%40mail.gmail.com.