diff --git a/unused/testdata/src/example.com/blank-function-parameter/blank.go b/unused/testdata/src/example.com/blank-function-parameter/blank.go new file mode 100644 index 000000000..e6b26c900 --- /dev/null +++ b/unused/testdata/src/example.com/blank-function-parameter/blank.go @@ -0,0 +1,6 @@ +package pkg + +type customType int //@ used("customType", true) + +func Foo(customType) {} //@ used("Foo", true), used("", true) +func bar(customType) {} //@ used("bar", false), quiet("") diff --git a/unused/unused.go b/unused/unused.go index 348d6badf..95e743a27 100644 --- a/unused/unused.go +++ b/unused/unused.go @@ -757,6 +757,9 @@ func (g *graph) read(node ast.Node, by types.Object) { fn := g.info.TypeOf(node).(*types.Signature) for params, i := fn.Params(), 0; i < params.Len(); i++ { g.see(params.At(i), by) + if params.At(i).Name() == "" { + g.use(params.At(i), by) + } } g.block(node.Body, by) @@ -1183,6 +1186,9 @@ func (g *graph) decl(decl ast.Decl, by types.Object) { fn := g.info.TypeOf(decl.Name).(*types.Signature) for params, i := fn.Params(), 0; i < params.Len(); i++ { g.see(params.At(i), obj) + if params.At(i).Name() == "" { + g.use(params.At(i), obj) + } } if decl.Name.Name == "_" {