Skip to content

Commit 784e53c

Browse files
committed
we can't compare location if either are nil
1 parent cfea169 commit 784e53c

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

internal/tfdiags/diagnostics_test.go

+29-2
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,35 @@ func TestAppendWithoutDuplicates(t *testing.T) {
713713
},
714714
},
715715
},
716+
"hcl.Diagnostic no-location": {
717+
// Extra can contain anything, and we don't know how to compare
718+
// those values, so we can't dedupe them
719+
func(diags Diagnostics) Diagnostics {
720+
diags = diags.Append(&hcl.Diagnostic{
721+
Severity: hcl.DiagError,
722+
Summary: "Something bad happened",
723+
Detail: "It was really, really bad.",
724+
})
725+
diags = diags.Append(&hcl.Diagnostic{
726+
Severity: hcl.DiagError,
727+
Summary: "Something bad happened",
728+
Detail: "It was really, really bad.",
729+
})
730+
return diags
731+
},
732+
[]diagFlat{
733+
{
734+
Severity: Error,
735+
Summary: "Something bad happened",
736+
Detail: "It was really, really bad.",
737+
},
738+
{
739+
Severity: Error,
740+
Summary: "Something bad happened",
741+
Detail: "It was really, really bad.",
742+
},
743+
},
744+
},
716745
}
717746

718747
for name, test := range tests {
@@ -736,9 +765,7 @@ func TestAppendWithoutDuplicates(t *testing.T) {
736765
}
737766

738767
if !reflect.DeepEqual(got, test.Want) {
739-
// t.Errorf("wrong result\ngot: %swant: %s", spew.Sdump(got), spew.Sdump(test.Want))
740768
t.Errorf("wrong result\ngot: %#v\nwant: %#v", got, test.Want)
741-
742769
}
743770
})
744771
}

internal/tfdiags/hcl.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ func (d hclDiagnostic) Equals(otherDiag ComparableDiagnostic) bool {
8585

8686
func hclRangeEquals(l, r *hcl.Range) bool {
8787
if l == nil || r == nil {
88-
return l == r
88+
return false
8989
}
90+
9091
if l.Filename != r.Filename {
9192
return false
9293
}

0 commit comments

Comments
 (0)