From: Keith Randall Date: Wed, 9 Feb 2022 19:42:54 +0000 (-0800) Subject: cmd/compile: don't panic when printing package-less symbols X-Git-Tag: go1.19beta1~1219 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=d81464e1eb69faab8bcf04015575d8a491e882b5;p=gostls13.git cmd/compile: don't panic when printing package-less symbols Some of the SSA pseudo-variables like the memory variable don't have a package. Print those gracefully instead of printing a panic. Fixes #51108 Change-Id: I5c29029356e045c5cf70909d6e63666ebc58ffaa Reviewed-on: https://go-review.googlesource.com/c/go/+/384614 Trust: Keith Randall Reviewed-by: Cherry Mui Run-TryBot: Cherry Mui TryBot-Result: Gopher Robot --- diff --git a/src/cmd/compile/internal/types/fmt.go b/src/cmd/compile/internal/types/fmt.go index 09814ac46d..93061d724d 100644 --- a/src/cmd/compile/internal/types/fmt.go +++ b/src/cmd/compile/internal/types/fmt.go @@ -157,6 +157,9 @@ func symfmt(b *bytes.Buffer, s *Sym, verb rune, mode fmtMode) { // symbols from the given package in the given mode. // If it returns the empty string, no qualification is needed. func pkgqual(pkg *Pkg, verb rune, mode fmtMode) string { + if pkg == nil { + return "" + } if verb != 'S' { switch mode { case fmtGo: // This is for the user