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
cmd/gc: problem with inlining + unexported field names #3552
Labels
Milestone
Comments
mt4swm's diagnosis was exactly right. It looks like the fix for issue #2687 may have been a bit too pragmatic. this unittest reproduces the issue: // one.go package one // issue #3552 type T struct { int } func (t T) F() int { return t.int } type U struct { int int } func (u U) F() int { return u.int } type lint int type V struct { lint } func (v V) F() int { return int(v.lint) } type W struct { lint lint } func (w W) F() int { return int(w.lint) } // two.go package two import "./one" func use() { var t one.T var u one.U var v one.V var w one.W _ = t.F() _ = u.F() _ = v.F() _ = w.F() } fixedbugs/bug434.dir/two.go:10: one.t.int undefined (cannot refer to unexported field or method one.int) (the others work fine, i just put them in for contrast) the export section in one.6 reads: $$ // exports package one import runtime "runtime" type @"".T struct { ? int } func (@"".t @"".T) F() (? int) { return @"".t.@"".int } type @"".U struct { @"".int int } func (@"".u @"".U) F() (? int) { return @"".u.@"".int } type @"".lint int type @"".V struct { ? @"".lint } func (@"".v @"".V) F() (? int) { return int(@"".v.@"".lint) } type @"".W struct { @"".lint @"".lint } func (@"".w @"".W) F() (? int) { return int(@"".w.@"".lint) } putting a debug statement in typecheck lookdot1 shows it's looking up lookdot1(@"/Users/lvd/Project/go3/test/one".int) and finding @"".int -> no match. An effective workaround is to not embed but name with the same name, eg. type T { string string } since the builtin types have no methods, i think this is indistinguishable from the original (except for this bug). |
Owner changed to @lvdlvd. |
See issue #2687 for a related problem. https://golang.org/cl/6866047/ |
This issue was closed by revision 9aef20e. Status changed to Fixed. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by mt4swm:
The text was updated successfully, but these errors were encountered: