Correct. I don't understand why you are saying that, though.
The argument I'm making is that x and y's *types* (not underlying) types
are identical (actually, the argument I *was* making was different, but
still had little to do with underlying types).

The spec <https://golang.org/ref/spec#Type_identity> says
> A defined type is always different from any other type. Otherwise, two
types are identical if their underlying type literals are structurally
equivalent; that is, they have the same literal structure and corresponding
components have identical types. In detail:
Now, as neither x's nor y's types are defined, the first sentence doesn't
apply. So we have to compare the structure of their underlying types. The
relevant part of that list is
> Two channel types are identical if they have identical element types and
the same direction.
So we have to check whether `error` and `interface{ Error() string }` are
identical. And that's where the question of whether error is a defined type
comes in (as I said, I'd argue that with the spec as-is it *probably*
isn't. It's at least not clearly stated).
If `error` is defined, then the two types are different; a defined type is
different from any other type.
If `error` is *not* defined, then we fall back to comparing the structure
of their underlying types. The structural comparison says they *are*
different.

So, really, using channels was maybe a bit of a red-herring. As I said, the
argument I was making still applies. But the argument that `error` and
`interface{ Error() string }` *should* be identical if error is not defined
is easier to make.

On Fri, May 8, 2020 at 6:08 PM Jan Mercl <0xj...@gmail.com> wrote:

> On Fri, May 8, 2020 at 5:57 PM Axel Wagner
> <axel.wagner...@googlemail.com> wrote:
> >
> > I'm happy to report, that I *think* I found an inconsistency with error
> not being a defined type:
> > https://play.golang.org/p/gpy6S17wzIM
>
> I don't follow. Type of x is not a defined type and neither is type of
> y. The underlying type of x is not the same as the underlying type of
> y.
>

-- 
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/CAEkBMfH6L_Q5nj3A%2BNrp%2Bb7mBBK6BwdjLpX9KAzxPWaz-ac3kQ%40mail.gmail.com.

Reply via email to