aboutsummaryrefslogtreecommitdiffstats
path: root/capturedrefrace.go
diff options
context:
space:
mode:
authorTeddy Wing2023-05-20 17:28:14 +0200
committerTeddy Wing2023-05-20 17:28:14 +0200
commitc064b2142aa81488e32be387393c494d98696a55 (patch)
tree3f8ce0d21eb464e283b300be7175f96016b459de /capturedrefrace.go
parentec33e063b86ae2c5208d856ee1a36259f342d5e0 (diff)
downloadgocapturedrefrace-c064b2142aa81488e32be387393c494d98696a55.tar.bz2
Fix panic when go statement calls non-function-literal
Diffstat (limited to 'capturedrefrace.go')
-rw-r--r--capturedrefrace.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/capturedrefrace.go b/capturedrefrace.go
index e7431ac..7ed7470 100644
--- a/capturedrefrace.go
+++ b/capturedrefrace.go
@@ -51,6 +51,7 @@
package capturedrefrace
import (
+ "fmt"
"go/ast"
"go/token"
"go/types"
@@ -93,12 +94,20 @@ func run(pass *analysis.Pass) (interface{}, error) {
case *ast.Ident:
// Get a function literal stored in a local variable.
funcLit, ok = funcLitFromIdent(goStmtFunc)
+
+ default:
+ return
}
if !ok {
return
}
// Inspect closure argument list.
+ fmt.Printf("ident: %#v\n", goStmt.Call.Fun)
+ fmt.Printf("pos: %#v\n", pass.Fset.Position(goStmt.Call.Fun.Pos()))
+ fmt.Printf("lit: %#v\n", funcLit)
+ fmt.Printf("type: %#v\n", funcLit.Type)
+ fmt.Printf("params: %#v\n", funcLit.Type.Params)
for _, arg := range funcLit.Type.Params.List {
// Report reference arguments.
_, ok := arg.Type.(*ast.StarExpr)