Happened to be working in cmd/compile/internal/gc/reflect.go and saw:
// Unnamed type. Grab the package from the first field, if any.
for _, f := range t.Fields().Slice() {
if f.Embedded != 0 {
continue
}
pkg = f.Sym.Pkg
break
}
I don't believe this is completely correct. There is no guarantee that the first non-embedded field will have a package. The commit message refers to
which the code handles correctly, but I think the code still mishandles
because it will look at X, which has no Pkg, instead of at i, which does. It should probably continue the loop until it finds something with a pkg.
/cc @crawshaw @griesemer @mdempsky
Happened to be working in cmd/compile/internal/gc/reflect.go and saw:
I don't believe this is completely correct. There is no guarantee that the first non-embedded field will have a package. The commit message refers to
which the code handles correctly, but I think the code still mishandles
because it will look at X, which has no Pkg, instead of at i, which does. It should probably continue the loop until it finds something with a pkg.
/cc @crawshaw @griesemer @mdempsky