Both string1 and str1 have defined types while the quoted specs rule says
"at least one of V or T is not a defined type.".

On Sun, Feb 23, 2020, 14:19 Jimu Yang <jimuy...@gmail.com> wrote:

> I am reading the doc about Assignability in Golang Specification
> <https://golang.org/ref/spec#Assignability> . It says:
>
> A value x is *assignable* to a variable
> <https://golang.org/ref/spec#Variables> of type T ("x is assignable to T")
> if one of the following conditions applies:
>
>    - ...
>    - x's type V and T have identical underlying types
>    <https://golang.org/ref/spec#Types> and at least one of V or T is not
>    a defined <https://golang.org/ref/spec#Type_definitions> type.
>    - ...
>
>
> type str string
>
> func main() {
> string1 := "string"
> var str1 str = "str1"
> str1 = string1 // cannot use string1 (type string) as type str in
> assignment
> }
>
>
> string1's type string and str have identical underlying type (string) and
> string is not a defined type.
>
> So why cannot i assign string1 to str1?
>
> --
> 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/8fedba03-5aa1-4227-80c5-686a87a45cdd%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/8fedba03-5aa1-4227-80c5-686a87a45cdd%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/CAA40n-VNBTMFFAETrgbXq8C6%3D5Ldjhr5mXQpQLMrHQPrnvM0YQ%40mail.gmail.com.

Reply via email to