aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/modload/load.go
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2021-05-04 16:41:13 -0400
committerBryan C. Mills <bcmills@google.com>2021-05-04 22:12:42 +0000
commit62a87f64b97d27e79d53a84e9006425aa234d7e6 (patch)
treee5b8b47fd14a2cbb4cd61ccaf5711b0abbe071f6 /src/cmd/go/internal/modload/load.go
parent6a6aa3278356e850f7530e75e857f539bf8cb51e (diff)
downloadgo-62a87f64b97d27e79d53a84e9006425aa234d7e6.tar.gz
go-62a87f64b97d27e79d53a84e9006425aa234d7e6.zip
cmd/go/internal/modload: only check root-promotion during tidy for lazy modules
In a lazy module, it is important that tidyRoots does not add any new roots because the dependencies of non-roots are pruned out. In an eager module, that property is not important (and does not hold in general) because no dependencies are ever pruned out. Fixes #45952 Change-Id: I5c95b5696b7112b9219e38af04e0dece7fb6e202 Reviewed-on: https://go-review.googlesource.com/c/go/+/316754 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
Diffstat (limited to 'src/cmd/go/internal/modload/load.go')
-rw-r--r--src/cmd/go/internal/modload/load.go18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/cmd/go/internal/modload/load.go b/src/cmd/go/internal/modload/load.go
index f434b399d8..c811029ab5 100644
--- a/src/cmd/go/internal/modload/load.go
+++ b/src/cmd/go/internal/modload/load.go
@@ -1065,13 +1065,17 @@ func loadFromRoots(ctx context.Context, params loaderParams) *loader {
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