ld.errorf("go: %v\n", err)
}
- // We continuously add tidy roots to ld.requirements during loading, so at
- // this point the tidy roots should be a subset of the roots of
- // ld.requirements. If not, there is a bug in the loading loop above.
- for _, m := range rs.rootModules {
- if v, ok := ld.requirements.rootSelected(m.Path); !ok || v != m.Version {
- ld.errorf("go: internal error: a requirement on %v is needed but was not added during package loading\n", m)
- base.ExitIfErrors()
+ if ld.requirements.depth == lazy {
+ // We continuously add tidy roots to ld.requirements during loading, so at
+ // this point the tidy roots should be a subset of the roots of
+ // ld.requirements, ensuring that no new dependencies are brought inside
+ // the lazy-loading horizon.
+ // If that is not the case, there is a bug in the loading loop above.
+ for _, m := range rs.rootModules {
+ if v, ok := ld.requirements.rootSelected(m.Path); !ok || v != m.Version {
+ ld.errorf("go: internal error: a requirement on %v is needed but was not added during package loading\n", m)
+ base.ExitIfErrors()
+ }
}
}
ld.requirements = rs
# dependency (or else no new root would be needed). An additional package D
# in its own module satisfies that condition, reproducing the bug.
-! go mod tidy
-stderr 'internal error'
+go mod tidy
+cmp go.mod go.mod.tidy
-- go.mod --
module example.net/a
example.net/d v0.1.0
)
+replace (
+ example.net/b v0.1.0 => ./b
+ example.net/c v0.1.0 => ./c
+ example.net/c v0.2.0 => ./c
+ example.net/d v0.1.0 => ./d
+)
+-- go.mod.tidy --
+module example.net/a
+
+go 1.16
+
+require (
+ example.net/c v0.2.0 // indirect
+ example.net/d v0.1.0
+)
+
replace (
example.net/b v0.1.0 => ./b
example.net/c v0.1.0 => ./c