From 754776850a62fa37ff6d68a8d5250497b2869b26 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Tue, 22 Sep 2020 12:43:16 +0700 Subject: [PATCH] cmd/compile: consistently use typekind when reporting invalid operation While at it, make "typekind" awares of "types.Ideal*" types. Passes toolstash-check. Change-Id: I092fa8c57ab6b8d9ba0f25d8e1ea44fba48675e5 Reviewed-on: https://go-review.googlesource.com/c/go/+/256438 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le Reviewed-by: Matthew Dempsky TryBot-Result: Go Bot --- src/cmd/compile/internal/gc/typecheck.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cmd/compile/internal/gc/typecheck.go b/src/cmd/compile/internal/gc/typecheck.go index 2c445567de..8e87fc9df0 100644 --- a/src/cmd/compile/internal/gc/typecheck.go +++ b/src/cmd/compile/internal/gc/typecheck.go @@ -151,8 +151,8 @@ var _typekind = []string{ } func typekind(t *types.Type) string { - if t.IsSlice() { - return "slice" + if t.IsUntyped() { + return fmt.Sprintf("%v", t) } et := t.Etype if int(et) < len(_typekind) { @@ -736,7 +736,7 @@ func typecheck1(n *Node, top int) (res *Node) { t = mixUntyped(l.Type, r.Type) } if dt := defaultType(t); !okfor[op][dt.Etype] { - yyerror("invalid operation: %v (operator %v not defined on %v)", n, op, t) + yyerror("invalid operation: %v (operator %v not defined on %s)", n, op, typekind(t)) n.Type = nil return n } -- 2.48.1