From 10d4f5fb1c7ef9cc4d4e5578c562ee20c552c50b Mon Sep 17 00:00:00 2001 From: chavacava Date: Sat, 18 Feb 2023 10:57:06 +0100 Subject: [PATCH] fix issue #792 (#793) --- rule/redefines-builtin-id.go | 3 +++ testdata/redefines-builtin-id.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/rule/redefines-builtin-id.go b/rule/redefines-builtin-id.go index 23dd85a..b3ff084 100644 --- a/rule/redefines-builtin-id.go +++ b/rule/redefines-builtin-id.go @@ -89,6 +89,9 @@ func (w *lintRedefinesBuiltinID) Visit(node ast.Node) ast.Visitor { case *ast.GenDecl: switch n.Tok { case token.TYPE: + if len(n.Specs) < 1 { + return nil + } typeSpec, ok := n.Specs[0].(*ast.TypeSpec) if !ok { return nil diff --git a/testdata/redefines-builtin-id.go b/testdata/redefines-builtin-id.go index 0593799..22e5975 100644 --- a/testdata/redefines-builtin-id.go +++ b/testdata/redefines-builtin-id.go @@ -29,3 +29,6 @@ var any int // MATCH /redefinition of the built-in type any/ const any = 1 // MATCH /redefinition of the built-in type any/ var i, copy int // MATCH /redefinition of the built-in function copy/ + +// issue #792 +type ()