I got a strange error message cannot use []feed literal (type []feed) as type []feed in field value
and after some fiddling and minimizing the source I figured out that this situation seems to produce the error:
type user struct {
Feeds []feed
}
type feed struct{}
func fn() {
type user struct {
Feeds []feed // seems to refer to the outer feed type
}
type feed struct{}
_ = user{
// "cannot use []feed literal (type []feed) as type []feed in field value"
Feeds: []feed{},
}
}
http://play.golang.org/p/gNIGhPwAgl
Is this the intended behaviour or a bug? I've spend some time reading the language specification but can't find anything explicitly stating how type declaration order in scopes should work. It's a bit unintuitive that order does not matter in the outer scope but does in the inner.