aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/modload/load.go
diff options
context:
space:
mode:
authorianwoolf <btw515wolf2@gmail.com>2022-08-31 23:34:26 +0800
committerBryan Mills <bcmills@google.com>2022-10-14 16:35:15 +0000
commit201759f959a6182215efe6070cf94dd4610cb3e9 (patch)
tree070914391ec6d7e4feba853980c49def8118b80d /src/cmd/go/internal/modload/load.go
parenta8ca70ff98dd088ff6afe57eafd553aa79732086 (diff)
downloadgo-201759f959a6182215efe6070cf94dd4610cb3e9.tar.gz
go-201759f959a6182215efe6070cf94dd4610cb3e9.zip
cmd/go/internal/modload: return error when tidyRoots fail
Fixes #51589 Change-Id: Ie9c56110754f4a435b22e2d7a86ae34b0bd28909 Reviewed-on: https://go-review.googlesource.com/c/go/+/427054 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
Diffstat (limited to 'src/cmd/go/internal/modload/load.go')
-rw-r--r--src/cmd/go/internal/modload/load.go27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/cmd/go/internal/modload/load.go b/src/cmd/go/internal/modload/load.go
index 09572bf1b1..fcd93ba94b 100644
--- a/src/cmd/go/internal/modload/load.go
+++ b/src/cmd/go/internal/modload/load.go
@@ -1151,22 +1151,23 @@ func loadFromRoots(ctx context.Context, params loaderParams) *loader {
rs, err := tidyRoots(ctx, ld.requirements, ld.pkgs)
if err != nil {
ld.errorf("go: %v\n", err)
- }
-
- if ld.requirements.pruning == pruned {
- // 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 graph-pruning 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()
+ base.ExitIfErrors()
+ } else {
+ if ld.requirements.pruning == pruned {
+ // 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 graph-pruning 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
}
- ld.requirements = rs
}
// Report errors, if any.