Yes, it's intended. From the draft:

More precisely, the underlying type of the type argument must be identical
> to the underlying type of one of the types in the type list.


Type-lists match by underlying type of both argument and the types in the
type-list. As SantaHappy and SantaSad both have underlying type `struct{}`,
they are the same.

On Tue, Aug 11, 2020 at 10:59 PM Rich Moyse <r...@moyse.us> wrote:

>
> Attempting to use a Type List in an Interface
> <https://go.googlesource.com/proposal/+/refs/heads/master/design/go2draft-type-parameters.md#type-lists-in-interface-types>
> to restrict the types allowed to instantiate a generic function (example
> in go2go <https://go2goplay.golang.org/p/BuJZv_-VQXh>).  The Type List
> within the Constraint Interface (Santa) contains only one struct type
> <https://golang.org/ref/spec#Struct_types> (SantaSad).  This struct type
> and a second, independent struct type (SantaHappy) both implement the
> Constraint Interface (Santa) specified as a type parameter for the generic
> function.  Given this situation, I expected the instantiation of the
> generic function with a type argument of the type (SantaSad), that appears
> in the Constraint's Interface Type List to succeed, which it does, and
> instantiating the generic function with the struct type, absent from the
> Type List (SantaHappy), to fail.  However, instead of failing, this second
> case succeeds.  Is this the intended behavior?
>
>
> --
> 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/44b6cb78-d143-437f-b4e0-f1cf8d642989n%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/44b6cb78-d143-437f-b4e0-f1cf8d642989n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAEkBMfF5TThWSMZ4SEN_k79J5V1p6C-GD-uo96cM3Ud%3DkEybKA%40mail.gmail.com.

Reply via email to