Skip to content

Commit

Permalink
unused: blank parameters are used
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikh committed Jan 30, 2023
1 parent 9397796 commit c30b155
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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("")
6 changes: 6 additions & 0 deletions unused/unused.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 == "_" {
Expand Down

0 comments on commit c30b155

Please sign in to comment.