From b2557286bbfa68c8ed788c456b22db662df70aef Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Tue, 11 Feb 2014 18:15:10 -0500 Subject: [PATCH] go.tools/go/ssa/interp: improve "no such method" error. LGTM=gri R=gri CC=golang-codereviews https://golang.org/cl/59740043 --- go/ssa/interp/interp.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/go/ssa/interp/interp.go b/go/ssa/interp/interp.go index 19ece8294cf..369fc8f5a50 100644 --- a/go/ssa/interp/interp.go +++ b/go/ssa/interp/interp.go @@ -177,7 +177,11 @@ func lookupMethod(i *interpreter, typ types.Type, meth *types.Func) *ssa.Functio case errorType: return i.errorMethods[meth.Id()] } - return i.prog.Method(i.prog.MethodSets.MethodSet(typ).Lookup(meth.Pkg(), meth.Name())) + sel := i.prog.MethodSets.MethodSet(typ).Lookup(meth.Pkg(), meth.Name()) + if sel == nil { + panic(fmt.Sprintf("%s has no method %s (of type %s)", typ, meth.Id(), meth.Type())) + } + return i.prog.Method(sel) } // visitInstr interprets a single ssa.Instruction within the activation