> go run .
[stdout]
var test/pkg1.Var1 test/pkg1.Alias1
var test/pkg1.Var2 int64
> go run . -godebug
[stdout]
var test/pkg1.Var1 test/pkg1.Alias1
var test/pkg1.Var2 int64
> go run . -godebug -needsyntax
[stdout]
var test/pkg1.Var1 test/pkg1.Alias1
var test/pkg1.Var2 test/pkg2.Alias2
> go run . -needsyntax
[stdout]
var test/pkg1.Var1 test/pkg1.Alias1
var test/pkg1.Var2 test/pkg2.Alias2
The first two results seem wrong; alias tracking is lost for the transitive dependency, given that we see the alias target int64 rather than the alias declared in the transitive dependency, pkg2.Alias2. This happens whether or not I set the GODEBUG flag, which should already be on by default in Go 1.23.
The issue only goes away once I set NeedSyntax, which presumably forces the current process to parse and typecheck all packages directly, rather than relying on the Go toolchain to typecheck transitive dependencies and store the results in GOCACHE, for the current process to load from a warm cache.
This bug seems to go away as of go version devel go1.24-493edb2973 2024-11-16 15:10:05 +0000 linux/amd64:
> go run .
[stdout]
var test/pkg1.Var1 test/pkg1.Alias1
var test/pkg1.Var2 test/pkg2.Alias2
> go run . -godebug
[stdout]
var test/pkg1.Var1 test/pkg1.Alias1
var test/pkg1.Var2 test/pkg2.Alias2
> go run . -godebug -needsyntax
[stdout]
var test/pkg1.Var1 test/pkg1.Alias1
var test/pkg1.Var2 test/pkg2.Alias2
> go run . -needsyntax
[stdout]
var test/pkg1.Var1 test/pkg1.Alias1
var test/pkg1.Var2 test/pkg2.Alias2
Take the testscript below:
With https://pkg.go.dev/github.com/rogpeppe/go-internal/cmd/testscript, I see:
The first two results seem wrong; alias tracking is lost for the transitive dependency, given that we see the alias target
int64
rather than the alias declared in the transitive dependency,pkg2.Alias2
. This happens whether or not I set the GODEBUG flag, which should already be on by default in Go 1.23.The issue only goes away once I set
NeedSyntax
, which presumably forces the current process to parse and typecheck all packages directly, rather than relying on the Go toolchain to typecheck transitive dependencies and store the results in GOCACHE, for the current process to load from a warm cache.This bug seems to go away as of
go version devel go1.24-493edb2973 2024-11-16 15:10:05 +0000 linux/amd64
: