diff --git a/src/cmd/compile/internal/types2/format.go b/src/cmd/compile/internal/types2/format.go index b61dfda1c81..d7aa2399c7b 100644 --- a/src/cmd/compile/internal/types2/format.go +++ b/src/cmd/compile/internal/types2/format.go @@ -23,6 +23,17 @@ func sprintf(qf Qualifier, tpSubscripts bool, format string, args ...any) string panic("got operand instead of *operand") case *operand: arg = operandString(a, qf) + case []*operand: + var buf strings.Builder + buf.WriteByte('[') + for i, x := range a { + if i > 0 { + buf.WriteString(", ") + } + buf.WriteString(operandString(x, qf)) + } + buf.WriteByte(']') + arg = buf.String() case syntax.Pos: arg = a.String() case syntax.Expr: diff --git a/src/go/types/format.go b/src/go/types/format.go index 550d22f5aeb..8df72f98e6f 100644 --- a/src/go/types/format.go +++ b/src/go/types/format.go @@ -24,6 +24,17 @@ func sprintf(fset *token.FileSet, qf Qualifier, tpSubscripts bool, format string panic("got operand instead of *operand") case *operand: arg = operandString(a, qf) + case []*operand: + var buf strings.Builder + buf.WriteByte('[') + for i, x := range a { + if i > 0 { + buf.WriteString(", ") + } + buf.WriteString(operandString(x, qf)) + } + buf.WriteByte(']') + arg = buf.String() case token.Pos: if fset != nil { arg = fset.Position(a).String()