diff --git a/internal/tfdiags/diagnostics_test.go b/internal/tfdiags/diagnostics_test.go index c3c12bc852..1cac152ef0 100644 --- a/internal/tfdiags/diagnostics_test.go +++ b/internal/tfdiags/diagnostics_test.go @@ -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) - } }) } diff --git a/internal/tfdiags/hcl.go b/internal/tfdiags/hcl.go index 1e6ccd3ec2..3531237477 100644 --- a/internal/tfdiags/hcl.go +++ b/internal/tfdiags/hcl.go @@ -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 }