From 1dd0319be36ae0b00d14caeb13912c1cc2f13d1f Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 22 Oct 2010 17:04:32 -0400 Subject: [PATCH] runtime: print unknown types in panic R=r CC=golang-dev https://golang.org/cl/2683041 --- src/pkg/runtime/error.go | 4 +++- src/pkg/runtime/print.c | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/pkg/runtime/error.go b/src/pkg/runtime/error.go index 673e77b2c1..289d78f49f 100644 --- a/src/pkg/runtime/error.go +++ b/src/pkg/runtime/error.go @@ -111,6 +111,8 @@ type stringer interface { String() string } +func typestring(interface{}) string + // For calling from C. // Prints an argument passed to panic. // There's room for arbitrary complexity here, but we keep it @@ -126,6 +128,6 @@ func printany(i interface{}) { case string: print(v) default: - print(i) + print("(", typestring(i), ") ", i) } } diff --git a/src/pkg/runtime/print.c b/src/pkg/runtime/print.c index aa207e3124..cf37886183 100644 --- a/src/pkg/runtime/print.c +++ b/src/pkg/runtime/print.c @@ -348,3 +348,11 @@ void { write(fd, "\n", 1); } + +void +·typestring(Eface e, String s) +{ + s = *e.type->string; + FLUSH(&s); +} + -- 2.50.0