Skip to content

Commit

Permalink
sourcebundle: Avoid infinite recursion with diagnosticInSourcePackage
Browse files Browse the repository at this point in the history
This wrapper type acts as an adapter to rewrite relative source paths in
diagnostics to be absolute source addresses instead, but it was
incorrectly calling its own Source method to get the starting value,
rather than calling that of its wrapped diagnostic, thereby causing
infinite recursion until stack overflow.
  • Loading branch information
apparentlymart committed Sep 8, 2023
1 parent 68d2059 commit 13e2db7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sourcebundle/diagnostics.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (diag diagnosticInSourcePackage) Severity() DiagSeverity {
}

func (diag diagnosticInSourcePackage) Source() DiagSource {
ret := diag.Source()
ret := diag.wrapped.Source()
if ret.Subject != nil && sourceaddrs.ValidSubPath(ret.Subject.Filename) {
newRng := *ret.Subject // shallow copy
newRng.Filename = diag.pkg.SourceAddr(newRng.Filename).String()
Expand Down

0 comments on commit 13e2db7

Please sign in to comment.