Thanks. So the only issue is that maybe the error message is a bit
sub-optimal.

Duncan


On Sun, 4 Jun 2023 at 06:35, Axel Wagner <axel.wagner...@googlemail.com>
wrote:

> That's a type alias, though. Not a type definition.
>
> The real issue is this part of the spec
> <https://go.dev/ref/spec#Type_identity>:
>
>> Two struct types are identical if they have the same sequence of fields,
>> and if corresponding fields have the same names, and identical types, and
>> identical tags. *Non-exported field names from different packages are
>> always different*.
>>
> So the two `struct{ f string }` are not identical, because they don't have
> the same same sequence of fields with the same names - the two "f" names
> are different, as they are from different packages.
>
>
>
> On Sun, Jun 4, 2023 at 2:19 AM Kurtis Rader <kra...@skepticism.us> wrote:
>
>> See https://go.dev/ref/spec#Type_definitions and
>> https://go.dev/ref/spec#Type_identity. In particular this statement: "The
>> new type is called a *defined type*. It is different
>> <https://go.dev/ref/spec#Type_identity> from any other type, including
>> the type it is created from."
>>
>> On Sat, Jun 3, 2023 at 5:03 PM Duncan Harris <dun...@harris3.org> wrote:
>>
>>> Why does this not work?
>>>
>>> https://go.dev/play/p/dodUj441xJS
>>>
>>> Produces the rather strange error message:
>>>
>>> ./prog.go:7:6: cannot use []t{…} (value of type []struct{f string}) as
>>> []struct{f string} value in argument to m.F
>>>
>>> --
>>> 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/396c63a7-4b0c-4f5e-8c0e-a1e45249e247n%40googlegroups.com
>>> <https://groups.google.com/d/msgid/golang-nuts/396c63a7-4b0c-4f5e-8c0e-a1e45249e247n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>
>>
>> --
>> Kurtis Rader
>> Caretaker of the exceptional canines Junior and Hank
>>
>> --
>> 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/CABx2%3DD8xgRUXQxOpzTuubqMg%3DN_m98VMUHGJUhXF4hMNqA8taQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/golang-nuts/CABx2%3DD8xgRUXQxOpzTuubqMg%3DN_m98VMUHGJUhXF4hMNqA8taQ%40mail.gmail.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/CAJFQHaSTx4GJBFKaJWfvPSAfZN3T7EV0SRJGpcYVQ%3D1L_30TMQ%40mail.gmail.com.

Reply via email to