var a interface{} = nil // (nil, nil)
var b *int = nil
var c interface{} = b // (*int, nil)
fmt.Println(a == c)
Of course most such cases are not that trivial, rather they're cases where a function takes an interface-valued parameter and checks for (param == nil), if the caller passes in an actual object there's no problem, if they pass in a concrete value no problem, but if they extract the nil literal to a concretely-typed context (variable) things go pear-shaped to various levels of fuckedness (depending what is done in the other branch).And that's vicious because something as seemingly innocuous as "extract variable" on an immutable literal can break your code.
var a interface{} = nil // (nil, nil)
fmt.Println(reflect.TypeOf(a) == nil)Ignoring the compatibility guarantee for the sake of discussion, I feel that nobody would notice if the compiler tomorrow started short-circuiting the equality check of interfaces against nil to return true if either tuple value is nil. But maybe I'm missing some use-case.
For example:
func returnsNil() error { return nil }
x := returnsNil()
// x is of type nil and value nil.