diff --git a/internal/report/shortnames.go b/internal/report/shortnames.go index 438624e8..4663573a 100644 --- a/internal/report/shortnames.go +++ b/internal/report/shortnames.go @@ -29,6 +29,10 @@ var ( // fileNameSuffixes returns a non-empty sequence of shortened file names // (in decreasing preference) that can be used to represent name. func fileNameSuffixes(name string) []string { + if name == "" { + // Avoid returning "." when symbol info is missing + return []string{""} + } return allSuffixes(filepath.ToSlash(filepath.Clean(name)), fileSepRE) } diff --git a/internal/report/shortnames_test.go b/internal/report/shortnames_test.go index 01cbcff9..820cd4d4 100644 --- a/internal/report/shortnames_test.go +++ b/internal/report/shortnames_test.go @@ -44,7 +44,7 @@ func TestFileNameSuffixes(t *testing.T) { } for _, c := range []testCase{ - test("empty", "", "."), + test("empty", "", ""), test("simple", "foo", "foo"), test("manypaths", "a/b/c", "a/b/c", "b/c", "c"), test("leading", "/a/b", "/a/b", "a/b", "b"),