]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: don't panic when printing package-less symbols
authorKeith Randall <khr@golang.org>
Wed, 9 Feb 2022 19:42:54 +0000 (11:42 -0800)
committerKeith Randall <khr@golang.org>
Tue, 1 Mar 2022 18:12:19 +0000 (18:12 +0000)
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 <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/cmd/compile/internal/types/fmt.go

index 09814ac46dd6e4415b9d1126d8f4e42a7d699024..93061d724d18b09486a9e5b35044d8606ad0c440 100644 (file)
@@ -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