Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions rule/redefines_builtin_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,15 @@ 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
}
id := typeSpec.Name.Name
if bt := w.builtInKind(id); bt != "" {
w.addFailure(n, fmt.Sprintf("redefinition of the built-in %s %s", bt, id))
for _, spec := range n.Specs {
typeSpec, ok := spec.(*ast.TypeSpec)
if !ok {
continue
}
id := typeSpec.Name.Name
if bt := w.builtInKind(id); bt != "" {
w.addFailure(n, fmt.Sprintf("redefinition of the built-in %s %s", bt, id))
}
}
case token.VAR, token.CONST:
for _, vs := range n.Specs {
Expand Down
5 changes: 5 additions & 0 deletions testdata/redefines_builtin_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,8 @@ const comparable = 1 // MATCH /redefinition of the built-in type comparable/

func foo4[comparable any]() { // MATCH /redefinition of the built-in type comparable/
}

type ( // MATCH /redefinition of the built-in function len/
Local int
len int
)