Re: [go-nuts] Go misfeature?

2017-10-25 Thread Ian Lance Taylor
On Wed, Oct 25, 2017 at 1:43 AM, Harald Fuchs wrote: > > I got bitten by what I'd say is a misfeature in Go: > > type T1 struct { > T2 > T3 > } > > type T2 struct { > T4 > } > > type T3 struct { > foo int > } > > type T4 struct { > foo int >

Re: [go-nuts] Go misfeature?

2017-10-25 Thread 'Axel Wagner' via golang-nuts
On Wed, Oct 25, 2017 at 11:02 AM, Lutz Horn wrote: > This prints "foo=2" which surprised me because I was unaware that T1 >> had got another foo via T3 (with less composition depth). >> >> If I put T4 directly into T1, Go would detect the ambiguity of t1.foo >> (because the

Re: [go-nuts] Go misfeature?

2017-10-25 Thread Lutz Horn
This prints "foo=2" which surprised me because I was unaware that T1 had got another foo via T3 (with less composition depth). If I put T4 directly into T1, Go would detect the ambiguity of t1.foo (because the composition depth is the same). There is no ambiguity because `T4.foo` is not

[go-nuts] Go misfeature?

2017-10-25 Thread Harald Fuchs
I got bitten by what I'd say is a misfeature in Go: type T1 struct { T2 T3 } type T2 struct { T4 } type T3 struct { foo int } type T4 struct { foo int } func main() { t1 := T1{ T2{ T4{ 1, }, }, T3{