On Thu, Jan 27, 2022 at 10:00 PM Ian Lance Taylor <
ia...@golang.org> wrote:
>
> On Thu, Jan 27, 2022 at 3:13 AM Manlio Perillo <
manlio....@gmail.com> wrote:
> >
> > On Thursday, January 27, 2022 at 11:42:19 AM UTC+1 Manlio Perillo wrote:
> [...]
> > Here is an alternate implementation:
> >
https://gotipplay.golang.org/p/mGm8DkqkuAX
> >
> > The code **seems** reasonable, but the compiler reports an error:
> > ./prog.go:24:12: *MyStruct does not implement structField
>
> I believe that that error message is correct. The constraint is for
> any type whose underlying type is "*struct{ x int }". The code is
> trying to instantiate with the type *MyStruct. The underlying type of
> *MyStruct is *MyStruct. It is not *struct{ x int }. So the type
> argument does not match the constraint.
>
However (from the first example) MyStruct matches struct {x int }.
It seems a bit confusing that *MyStruct does not match *struct {x int }.
Thanks
Manlio