> but we even don't know how the builtin byte and uint8 are defined?

Yes we know, see: https://golang.org/ref/spec#Numeric_types

> How do you know their type names originate in the same TypeSpec?
<https://golang.org/ref/spec#Type_declarations>

Because that's how the semantics of predeclared aliases are specified,
regardless of no real source code definition for the type specification
exists.

Let's assume named types byte and uint8 do not share the same type
specification. So the compiler must reject this code (
https://play.golang.org/p/EtiJNC_NIZ):

        package main

        func main() {
                var b byte
                var u uint8
                b = u
                _ = b
        }

It compiles just fine. OTOH this code (https://play.golang.org/p/Jq9eEGGUwy
):

        package main

        type uint8 byte

        func main() {
                var b byte
                var u uint8
                b = u
                _ = b
        }


Is rejected because the types are not identical and assignability rules (
https://golang.org/ref/spec#Assignability) demand that when both sides are
named types.

Q.E.D.

-- 

-j

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to