From f128e626db139fbf9b0a715b07661464add0cf6b Mon Sep 17 00:00:00 2001 From: Heschi Kreinick Date: Wed, 16 Sep 2020 14:10:10 -0400 Subject: [PATCH] internal/memoize: show key type in panics gopls uses a lot of keys that are just strings, which print without any type information. Include the type of the key explicitly. Updates golang/go#41415. Change-Id: I01cfc685184e7b44c1f562b6536f173da5ae4830 Reviewed-on: https://go-review.googlesource.com/c/tools/+/255357 Trust: Heschi Kreinick Reviewed-by: Robert Findley --- internal/memoize/memoize.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/memoize/memoize.go b/internal/memoize/memoize.go index c10dc8e8a5..3c7d3c168a 100644 --- a/internal/memoize/memoize.go +++ b/internal/memoize/memoize.go @@ -228,7 +228,7 @@ func (g *Generation) Inherit(h *Handle) { h.mu.Lock() defer h.mu.Unlock() if h.state == stateDestroyed { - panic(fmt.Sprintf("inheriting destroyed handle %#v into generation %v", h.key, g.name)) + panic(fmt.Sprintf("inheriting destroyed handle %#v (type %T) into generation %v", h.key, h.key, g.name)) } h.generations[g] = struct{}{} } @@ -280,7 +280,7 @@ func (h *Handle) Get(ctx context.Context, g *Generation, arg Arg) (interface{}, return h.value, nil case stateDestroyed: h.mu.Unlock() - err := fmt.Errorf("Get on destroyed entry %#v in generation %v", h.key, g.name) + err := fmt.Errorf("Get on destroyed entry %#v (type %T) in generation %v", h.key, h.key, g.name) if *panicOnDestroyed { panic(err) }