The compiler is behaving as designed in both cases. See https://golang.org/issue/25187 (and the associated https://golang.org/issue/25141).
On Saturday, December 8, 2018 at 12:33:48 PM UTC-5, Jan Mercl wrote: > > This code compiles fine > > package main > > type node struct { > next *node > } > > func main() {} > > (https://play.golang.org/p/ZYg0EciQnOQ) > > This code does not > > package main > > type node = struct { > next *node > } > > func main() {} > > (https://play.golang.org/p/gWWX8ngPsS6) > > The error is > > prog.go:3:6: invalid recursive type alias node > prog.go:3:6: node uses <T> > prog.go:3:13: <T> uses node > > The specification remains silent about what is considered "invalid > recursive type alias" so I'm not sure, but it seems to me the first and > second programs should both compile fine. In both cases, so to say "the > pointer breaks the cycle" while type checking. But maybe/probably I'm > mistaken. > > Can anybody enlighten me please and explain if the compiler is right or if > it's a bug? > > Thanks in advance. > > -- > > -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.