we can't compare location if either are nil

pull/36825/head
James Bardin 1 year ago
parent c6c21a89a1
commit 291d26ce19

@ -733,6 +733,35 @@ func TestAppendWithoutDuplicates(t *testing.T) {
},
},
},
"hcl.Diagnostic no-location": {
// Extra can contain anything, and we don't know how to compare
// those values, so we can't dedupe them
func(diags Diagnostics) Diagnostics {
diags = diags.Append(&hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: "Something bad happened",
Detail: "It was really, really bad.",
})
diags = diags.Append(&hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: "Something bad happened",
Detail: "It was really, really bad.",
})
return diags
},
[]diagFlat{
{
Severity: Error,
Summary: "Something bad happened",
Detail: "It was really, really bad.",
},
{
Severity: Error,
Summary: "Something bad happened",
Detail: "It was really, really bad.",
},
},
},
}
for name, test := range tests {
@ -756,9 +785,7 @@ func TestAppendWithoutDuplicates(t *testing.T) {
}
if !reflect.DeepEqual(got, test.Want) {
// t.Errorf("wrong result\ngot: %swant: %s", spew.Sdump(got), spew.Sdump(test.Want))
t.Errorf("wrong result\ngot: %#v\nwant: %#v", got, test.Want)
}
})
}

@ -85,8 +85,9 @@ func (d hclDiagnostic) Equals(otherDiag ComparableDiagnostic) bool {
func hclRangeEquals(l, r *hcl.Range) bool {
if l == nil || r == nil {
return l == r
return false
}
if l.Filename != r.Filename {
return false
}

Loading…
Cancel
Save