diff options
author | Teddy Wing | 2023-05-16 05:00:00 +0200 |
---|---|---|
committer | Teddy Wing | 2023-05-16 05:00:00 +0200 |
commit | c084c38557e96ea7dc57aaff172859245d1ee344 (patch) | |
tree | 26c0441a4cb741ca46b033f3b07789c4e0bf8f5a | |
parent | 555bdd6e949ede8135ddb9421e7d00aac8337396 (diff) | |
download | gocapturedrefrace-c084c38557e96ea7dc57aaff172859245d1ee344.tar.bz2 |
Ideas for using scope LookupParent to check if variable is local
-rw-r--r-- | gocapturedrefrace.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/gocapturedrefrace.go b/gocapturedrefrace.go index 79c6d87..c49b399 100644 --- a/gocapturedrefrace.go +++ b/gocapturedrefrace.go @@ -121,6 +121,12 @@ func checkClosure( fmt.Println("LookupParent:") fmt.Printf(" scope: %#v\n", scope) fmt.Printf(" obj : %#v\n", scopeObj) + // If scope and scopeObj are nil, then variable is local + + // This also means variable is local. + if funcScope == scope { + fmt.Printf("In function scope %v\n", scopeObj) + } pass.Reportf( ident.Pos(), |