Hello folks, I've stumbled over a thing and I don't understand if what I've found is intentionally possible by design...
https://go.dev/play/p/SIxOV1FnTzX?v=gotip Why can I compare int with == when it was instantiated from the "any" type parameter? The origin of my question is my implementation of a left right map which I've ported to generics. While doing so I've uncovered a couple bugs in Jetbrains GoLand and reported them. Except this one, because I've overlooked it and I now am confused: https://github.com/jwkohnen/lrmap/blob/a6b9a6715069a7ad24de7cf84fe949dd7f194c0a/lrmap_test.go#L26 In this line I compare two int values with !=, and this code compiles. Though, those value types were instantiated from the "any" type constraint. GoLand reports an error in that line "Invalid operation: _v != v (the operator != is not defined on V)". >From my reading of the generics proposal GoLand is right, but the compiler says otherwise. How exactly are the operations that are defined on an "any" type inferred? Sorry if the answer is right there in the proposal; my reading comprehension fluctuates wildly these days. Cheers, Johannes -- 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/CA%2B5f5upYHUvABKSJhtdQL-qRg6FKhg-N7c9433zv%2BTXbteT93Q%40mail.gmail.com.