-
Notifications
You must be signed in to change notification settings - Fork 18k
go/types: type-check embedded methods in wrong scope #25008
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
Comments
/cc @griesemer |
@nabice Thanks for this report and the (correct) analysis! Fix forthcoming. A shorter reproducer:
|
Change https://golang.org/cl/109139 mentions this issue: |
@griesemer we just had another instance of this via gopherjs/gopherjs#808 - would you consider back-porting this fix to the 1.10 series? |
Edit: fixed typo below in second paragraph. Just to add a bit more colour. Using Using Here are the repro steps I used:
|
@myitcv While the CL https://go-review.googlesource.com/c/go/+/109139 fixed this specific issue, the fix is in a (significant) chunk of code that doesn't even exist in the 1.10 version of go/types (https://tip.golang.org/src/go/types/interfaces.go was added, and https://golang.org/src/go/types/ordering.go was removed). So back-porting this fix implies a much larger change than what meets the eye. You may be able to (temporarily) work around the problem by re-arranging some your source code (relative order of method and interface declarations). It doesn't always work but it's worth a try. Is there a reason not to move to 1.11 in gorgonia, or perhaps (for now) vendor the latest version of go/types? |
Ah, I hadn't realised this. Thank you for clarifying.
Excellent suggestion, thank you. We can do that within GopherJS (which is ultimately where we get bitten by this) until we release GopherJS 1.11 that corresponds to Go 1.11. |
Per golang/go#25008 (comment) the fix for method set calculation will not be back ported to Go 1.10. Instead gri suggests we vendor the latest version of go/types. This PR does just that. It is effectively a temporary sticking plaster until Go 1.11 lands, or more specifically until we release GopherJS for Go 1.11. In order to successfully vendor go/types, however, we need to move compiler/vendor to the repo root (because build also uses go/types). And because golang.org/x/tools/go/gcexportdata and golang.org/x/tools/go/types/typeutil also reference go/types we need to vendor them as well. vendor/vendor.json is updated using govendor, with the one exception being a manual addition for go/types (govendor doesn't appear to understand how to vendor a standard library package). Fixes gopherjs#808.
Per golang/go#25008 (comment) the fix for method set calculation will not be back ported to Go 1.10. Instead gri suggests we vendor the latest version of go/types. This PR does just that. It is effectively a temporary sticking plaster until Go 1.11 lands, or more specifically until we release GopherJS for Go 1.11. In order to successfully vendor go/types, however, we need to move compiler/vendor to the repo root (because build also uses go/types). And because golang.org/x/tools/go/gcexportdata and golang.org/x/tools/go/types/typeutil also reference go/types we need to vendor them as well. vendor/vendor.json is updated using govendor, with the one exception being a manual addition for go/types (govendor doesn't appear to understand how to vendor a standard library package). Fixes gopherjs#808.
Per golang/go#25008 (comment) the fix for method set calculation will not be back ported to Go 1.10. Instead gri suggests we vendor the latest version of go/types. This PR does just that. It is effectively a temporary sticking plaster until Go 1.11 lands, or more specifically until we release GopherJS for Go 1.11. In order to successfully vendor go/types, however, we need to move compiler/vendor to the repo root (because build also uses go/types). And because golang.org/x/tools/go/gcexportdata and golang.org/x/tools/go/types/typeutil also reference go/types we need to vendor them as well. vendor/vendor.json is updated using govendor, with the one exception being a manual addition for go/types (govendor doesn't appear to understand how to vendor a standard library package). Fixes gopherjs#808.
Per golang/go#25008 (comment) the fix for method set calculation will not be back ported to Go 1.10. Instead gri suggests we vendor the latest version of go/types. This PR does just that. It is effectively a temporary sticking plaster until Go 1.11 lands, or more specifically until we release GopherJS for Go 1.11. In order to successfully vendor go/types, however, we need to move compiler/vendor to the repo root (because build also uses go/types). And because golang.org/x/tools/go/gcexportdata and golang.org/x/tools/go/types/typeutil also reference go/types we need to vendor them as well. vendor/vendor.json is updated using govendor, with the one exception being a manual addition for go/types (govendor doesn't appear to understand how to vendor a standard library package). Fixes gopherjs#808.
Per golang/go#25008 (comment) the fix for method set calculation will not be back ported to Go 1.10. Instead gri suggests we vendor the latest version of go/types. This PR does just that. It is effectively a temporary sticking plaster until Go 1.11 lands, or more specifically until we release GopherJS for Go 1.11. In order to successfully vendor go/types, however, we need to move compiler/vendor to the repo root (because build also uses go/types). And because golang.org/x/tools/go/gcexportdata and golang.org/x/tools/go/types/typeutil also reference go/types we need to vendor them as well. vendor/vendor.json is updated using govendor, with the one exception being a manual addition for go/types (govendor doesn't appear to understand how to vendor a standard library package). Fixes gopherjs#808.
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version devel +d11df8baa8 Sun Apr 22 22:32:11 2018 +0000 linux/amd64
Does this issue reproduce with the latest release?
no, only recent commit d11df8b
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOCACHE="/home/nabice/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/nabice/go:/home/nabice/skygo/go"
GORACE=""
GOROOT="/home/nabice/source/go"
GOTMPDIR=""
GOTOOLDIR="/home/nabice/source/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build162693936=/tmp/go-build -gno-record-gcc-switches"
What did you do?
Two go files:
a.go
b.go
go vet a.go b.go
runs OKgo vet b.go a.go
failed.The reason is that, in file src/go/types/interfaces.go:226, We pass wrong context(scope) to lookup for "io". So typecheck cannot found io.Reader.
stack trace:
When we check
b.go
firstly,go
tries to getA
's info fromb.go
's scopeWhat did you expect to see?
No error found
What did you see instead?
The text was updated successfully, but these errors were encountered: