From 058da7c2bda9bf0d251780483ee7c9745a443b38 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Wed, 2 Sep 2020 22:39:20 +0300 Subject: [PATCH] compiler: getFuncNameFromDecl for methods on pointers Declaration has *ast.StarExpr type in case of method on pointer. --- pkg/compiler/func_scope.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/compiler/func_scope.go b/pkg/compiler/func_scope.go index 2eca590fe..5fa4613d1 100644 --- a/pkg/compiler/func_scope.go +++ b/pkg/compiler/func_scope.go @@ -77,7 +77,12 @@ func (c *codegen) newFuncScope(decl *ast.FuncDecl, label uint16) *funcScope { func (c *codegen) getFuncNameFromDecl(pkgPath string, decl *ast.FuncDecl) string { name := decl.Name.Name if decl.Recv != nil { - name = decl.Recv.List[0].Type.(*ast.Ident).Name + "." + name + switch t := decl.Recv.List[0].Type.(type) { + case *ast.Ident: + name = t.Name + "." + name + case *ast.StarExpr: + name = t.X.(*ast.Ident).Name + "." + name + } } return c.getIdentName(pkgPath, name) }