From 21373e26ed585b0b7cbc29f31b71744ce6409934 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Tue, 16 May 2023 20:31:28 +0200 Subject: Ignore any identifier that isn't a *types.Var Otherwise we can get `*types.TypeName` identifiers, like the variable types in the closure's argument list. We only want to inspect variables. --- gocapturedrefrace.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gocapturedrefrace.go b/gocapturedrefrace.go index 7f5d16d..3174a09 100644 --- a/gocapturedrefrace.go +++ b/gocapturedrefrace.go @@ -133,6 +133,11 @@ func checkClosure( return true } + _, ok = scopeObj.(*types.Var) + if !ok { + return true + } + if funcScope != scope { pass.Reportf( ident.Pos(), @@ -141,7 +146,6 @@ func checkClosure( ) } - // TODO: Ignore `aStruct` type // TODO: Report references in argument list return true -- cgit v1.2.3