@@ -212,7 +212,11 @@ func modTidyDiagnostics(ctx context.Context, snapshot source.Snapshot, pm *sourc
212
212
// vice versa.
213
213
srcDiag , err := directnessDiagnostic (pm .Mapper , req , snapshot .View ().Options ().ComputeEdits )
214
214
if err != nil {
215
- return nil , err
215
+ // We're probably in a bad state if we can't compute a
216
+ // directnessDiagnostic, but try to keep going so as to not suppress
217
+ // other, valid diagnostics.
218
+ event .Error (ctx , "computing directness diagnostic" , err )
219
+ continue
216
220
}
217
221
diagnostics = append (diagnostics , srcDiag )
218
222
}
@@ -428,7 +432,14 @@ func switchDirectness(req *modfile.Require, m *protocol.ColumnMapper, computeEdi
428
432
// Change the directness in the matching require statement. To avoid
429
433
// reordering the require statements, rewrite all of them.
430
434
var requires []* modfile.Require
435
+ seenVersions := make (map [string ]string )
431
436
for _ , r := range copied .Require {
437
+ if seen := seenVersions [r .Mod .Path ]; seen != "" && seen != r .Mod .Version {
438
+ // Avoid a panic in SetRequire below, which panics on conflicting
439
+ // versions.
440
+ return nil , fmt .Errorf ("%q has conflicting versions: %q and %q" , r .Mod .Path , seen , r .Mod .Version )
441
+ }
442
+ seenVersions [r .Mod .Path ] = r .Mod .Version
432
443
if r .Mod .Path == req .Mod .Path {
433
444
requires = append (requires , & modfile.Require {
434
445
Mod : r .Mod ,
0 commit comments