New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compile error when imported package method returns anonymous struct with embedded field #6773
Labels
Comments
Comment 2 by vincent@callanan.ie: Just tested on 1.2rc4 (Windows/AMD64). Bug is not present. |
Comment 3 by vincent@callanan.ie: Ok, while bug is not present in 1.2rc4, You may still need to patch 1.1.2 So here is relevant part of thread: --------------------------------------------- This version works.... package pkgA type item struct { val int } type ReadOnlyItem struct { *item } func (this *item) Val() int { return this.val } func GetItem() ReadOnlyItem { return ReadOnlyItem{&item{1234}} } ----------------------------------------------- package main import ( "....../pkgA" "fmt" ) func main() { fmt.Println(pkgA.GetItem().Val()) } ------------------------------------------ But when I replace func GetItem() in pkgA with func GetItem() struct{ *item } { return struct{ *item }{&item{1234}} } pkgA compiles ok, but I get the following compile error in package main at the import "pkgA" line: unknown struct {} field 'pkgA.item' in struct literal |
This is issue #5910 |
Comment 5 by vincent@callanan.ie: Thanks, I saw that bug but thought it had something to do with channels. Out of curiosity, there appears to be some trepidation about this whole area i.e. anonymous structs/embedded fields/inlining. Can we assume that the relevant code is "reasonably clean" at this point (1.2rc4)? |
As far as we know the tools work correctly. Of course bugs are always possible. I don't see any trepidation myself. Status changed to Duplicate. Merged into issue #5910. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by vincent@callanan.ie:
The text was updated successfully, but these errors were encountered: