diff --git a/rule/unconditional-recursion.go b/rule/unconditional-recursion.go index d4da015..930b486 100644 --- a/rule/unconditional-recursion.go +++ b/rule/unconditional-recursion.go @@ -61,8 +61,10 @@ func (w lintUnconditionalRecursionRule) Visit(node ast.Node) ast.Visitor { case *ast.FuncDecl: var rec *ast.Ident switch { - case n.Recv == nil || n.Recv.NumFields() < 1 || len(n.Recv.List[0].Names) < 1: + case n.Recv == nil: rec = nil + case n.Recv.NumFields() < 1 || len(n.Recv.List[0].Names) < 1: + rec = &ast.Ident{Name: "_"} default: rec = n.Recv.List[0].Names[0] } diff --git a/testdata/unconditional-recursion.go b/testdata/unconditional-recursion.go index 7a3d30f..b626769 100644 --- a/testdata/unconditional-recursion.go +++ b/testdata/unconditional-recursion.go @@ -178,3 +178,12 @@ func urn17(ch chan int) { } urn17(ch) // MATCH /unconditional recursive call/ } + +// Tests for #596 +func (*fooType) BarFunc() { + BarFunc() +} + +func (_ *fooType) BazFunc() { + BazFunc() +}