golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.84k stars 17.65k forks source link

cmd/go: Errors sometimes reported out of source error #26452

Closed btracey closed 6 years ago

btracey commented 6 years ago

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

1.11beta1 go version devel +a12c1f26e4 Tue Jun 26 20:00:51 2018 +0000 darwin/amd64

What operating system and processor architecture are you using (go env)?

go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/brendan/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/brendan/Documents/mygo"
GOPROXY=""
GORACE=""
GOROOT="/Users/brendan/gover/go"
GOTMPDIR=""
GOTOOLDIR="/Users/brendan/gover/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/l6/mhj4qjrj4437b_lgfz9pm1rw0000gn/T/go-build491566060=/tmp/go-build -gno-record-gcc-switches -fno-common"
VGOMODROOT=""

What did you do?

Doing some code refactoring, and noticed that the vet half of the compile errors were sometimes printing out of source order

brendan:~/Documents/mygo/src/gonum.org/v1/gonum/optimize$ go test -v
# gonum.org/v1/gonum/optimize [gonum.org/v1/gonum/optimize.test]
./unconstrained_test.go:1185:18: undefined: Global
./unconstrained_test.go:1249:20: undefined: Global
./unconstrained_test.go:1302:10: undefined: Global
./unconstrained_test.go:1319:17: undefined: Global
# gonum.org/v1/gonum/optimize
./unconstrained_test.go:1319:17: undeclared name: Global
./unconstrained_test.go:1302:10: undeclared name: Global
./unconstrained_test.go:1185:18: undeclared name: Global
./unconstrained_test.go:1249:20: undeclared name: Global
vet: typecheck failures

I've made a .zip file of the code at the state right now that can be shared. It comes from a package with a lot of code, so it's hard to produce a minimal reproducer.

What did you expect to see?

I would have expected the errors to come in the same order as the compile errors.

josharian commented 6 years ago

Dup of #26236?

FiloSottile commented 6 years ago

Closing as duplicate of #26236, please let me know if you think that's not correct.