Closed
Description
Should the spec clarify when a struct comparison panics?
e.g.
https://play.golang.org/p/4NUu89RI27t
package main
import "fmt"
func cmp(a, b S) {
defer func() {
if recover() != nil {
fmt.Println("panic")
}
}()
if a == b {
fmt.Println("equal")
} else {
fmt.Println("not-equal")
}
}
type S struct{ a, b interface{} }
func main() {
var f func()
cmp(S{1, f}, S{2, f})
cmp(S{f, 1}, S{f, 2})
}
Is it okay for implementations to have different answers to those two prints?
(Background: https://go-review.googlesource.com/c/go/+/230207, cmd/compile: improve generated eq algs for structs containing interfaces
from @josharian)