Skip to content

cmd/go: fails to run test in generics-using package that has a dep not in go.mod #59980

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

Closed
bradfitz opened this issue May 4, 2023 · 2 comments
Assignees
Milestone

Comments

@bradfitz
Copy link
Contributor

bradfitz commented May 4, 2023

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

Both:

  • go version go1.20.4 darwin/arm64
  • go version devel go1.21-5c51e9f45b Thu May 4 18:03:04 2023 +0000 darwin/arm64

Does this issue reproduce with the latest release?

Yes

What did you do?

I tried to run tests of a package in another module, where my current module didn't have those test deps in go.mod.

You get weird -lang mismatches (is it synthesizing some fake module behind the scenes and not filling something out?) instead of either working or failing nicely.

Repro at https://github.com/bradfitz/go-test-bug-repro

$ go version
go version go1.20.4 darwin/arm64

$ go test tailscale.com/net/dns/resolver
# github.com/miekg/dns
embedding interface element ~[]string requires go1.18 or later (-lang was set to go1.16; check go.mod)
../go/pkg/mod/github.com/miekg/[email protected]/msg.go:549:12: type parameter requires go1.18 or later (-lang was set to go1.16; check go.mod)
../go/pkg/mod/github.com/miekg/[email protected]/msg.go:549:14: embedding interface element ~[]byte | ~string requires go1.18 or later (-lang was set to go1.16; check go.mod)
../go/pkg/mod/github.com/miekg/[email protected]/msg.go:553:16: type parameter requires go1.18 or later (-lang was set to go1.16; check go.mod)
../go/pkg/mod/github.com/miekg/[email protected]/types.go:1605:17: type parameter requires go1.18 or later (-lang was set to go1.16; check go.mod)
../go/pkg/mod/github.com/miekg/[email protected]/types.go:1605:19: predeclared any requires go1.18 or later (-lang was set to go1.16; check go.mod)
../go/pkg/mod/github.com/miekg/[email protected]/types.go:1605:26: embedding interface element ~[]E requires go1.18 or later (-lang was set to go1.16; check go.mod)
../go/pkg/mod/github.com/miekg/[email protected]/clientconfig.go:71:25: implicit function instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
../go/pkg/mod/github.com/miekg/[email protected]/defaults.go:211:12: implicit function instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
../go/pkg/mod/github.com/miekg/[email protected]/edns.go:523:63: implicit function instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
../go/pkg/mod/github.com/miekg/[email protected]/edns.go:523:63: too many errors
FAIL	tailscale.com/net/dns/resolver [build failed]
FAIL

$ go get github.com/miekg/[email protected]    # <---- the workaround

$ go test tailscale.com/net/dns/resolver
ok  	tailscale.com/net/dns/resolver	0.160s

$ go mod tidy

$ go test tailscale.com/net/dns/resolver
# github.com/miekg/dns
embedding interface element ~[]string requires go1.18 or later (-lang was set to go1.16; check go.mod)
../go/pkg/mod/github.com/miekg/[email protected]/msg.go:549:12: type parameter requires go1.18 or later (-lang was set to go1.16; check go.mod)
../go/pkg/mod/github.com/miekg/[email protected]/msg.go:549:14: embedding interface element ~[]byte | ~string requires go1.18 or later (-lang was set to go1.16; check go.mod)
../go/pkg/mod/github.com/miekg/[email protected]/msg.go:553:16: type parameter requires go1.18 or later (-lang was set to go1.16; check go.mod)
../go/pkg/mod/github.com/miekg/[email protected]/types.go:1605:17: type parameter requires go1.18 or later (-lang was set to go1.16; check go.mod)
../go/pkg/mod/github.com/miekg/[email protected]/types.go:1605:19: predeclared any requires go1.18 or later (-lang was set to go1.16; check go.mod)
../go/pkg/mod/github.com/miekg/[email protected]/types.go:1605:26: embedding interface element ~[]E requires go1.18 or later (-lang was set to go1.16; check go.mod)
../go/pkg/mod/github.com/miekg/[email protected]/clientconfig.go:71:25: implicit function instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
../go/pkg/mod/github.com/miekg/[email protected]/defaults.go:211:12: implicit function instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
../go/pkg/mod/github.com/miekg/[email protected]/edns.go:523:63: implicit function instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
../go/pkg/mod/github.com/miekg/[email protected]/edns.go:523:63: too many errors
FAIL	tailscale.com/net/dns/resolver [build failed]
FAIL

/cc @bcmills @matloob @ianlancetaylor

@bcmills bcmills self-assigned this May 4, 2023
@bcmills bcmills added this to the Go1.21 milestone May 4, 2023
@bcmills
Copy link
Contributor

bcmills commented May 4, 2023

This is an unfortunate failure mode of #56222.

From a build at CL 489075 I see:

~/tmp/go-test-bug-repro$ go mod why github.com/miekg/dns
# github.com/miekg/dns
go-test-bug-repro
tailscale.com/tsnet
tailscale.com/ipn/ipnlocal
tailscale.com/net/dns/resolver
tailscale.com/net/dns/resolver.test
github.com/miekg/dns

~/tmp/go-test-bug-repro$ go test tailscale.com/net/dns/resolver
# tailscale.com/net/dns/resolver
../../pkg/mod/[email protected]/net/dns/resolver/tsdns_server_test.go:13:2: github.com/miekg/[email protected]: missing go.sum entry for go.mod file; to add it:
        go mod download github.com/miekg/dns
FAIL    tailscale.com/net/dns/resolver [setup failed]
FAIL

~/tmp/go-test-bug-repro$ go mod tidy -go=1.21

~/tmp/go-test-bug-repro$ go test tailscale.com/net/dns/resolver
ok      tailscale.com/net/dns/resolver  0.030s

@bcmills
Copy link
Contributor

bcmills commented May 4, 2023

Duplicate of #56222

@bcmills bcmills marked this as a duplicate of #56222 May 4, 2023
@bcmills bcmills closed this as not planned Won't fix, can't repro, duplicate, stale May 4, 2023
@golang golang locked and limited conversation to collaborators May 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants