Skip to content

Commit aabd452

Browse files
Added quick fix to declFullNameDiscriminator
1 parent 58c2277 commit aabd452

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

compiler/declNames.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,15 @@ func declFullNameDiscriminator(pos token.Pos, fSet *token.FileSet) string {
111111
if !pos.IsValid() {
112112
return ``
113113
}
114+
if fSet.File(pos) == nil {
115+
// TODO(grantnelson-wf): Figure out why this happens sometimes.
116+
// Occationally the position is valid but the file can not be found so would
117+
// panic when getting `p`.
118+
// I've seen it happen in some file like `goarch_js.go` while testing but
119+
// I haven't tracked it down yet. It should be simple to reproduce though.
120+
fmt.Printf(`Warning: declFullNameDiscriminator called with invalid fSet for pos %v\n`, pos)
121+
return ``
122+
}
114123
p := fSet.Position(pos)
115124
return fmt.Sprintf("@%s:%d:%d", path.Base(p.Filename), p.Line, p.Column)
116125
}

0 commit comments

Comments
 (0)