Skip to content

Commit

Permalink
fix #13: don't follow the postion of the global variable: it clearly is
Browse files Browse the repository at this point in the history
not a local variable.
  • Loading branch information
kyoh86 committed Nov 16, 2022
1 parent 4ad8bcf commit 1977096
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions exportloopref.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ func (s *Searcher) isVar(loop ast.Node, expr ast.Expr) bool {
}
switch typed := expr.(type) {
case (*ast.Ident):
if typed.Obj == nil {
return false // global var in another file (ref: #13)
}
_, isVar := vars[typed.Obj.Pos()]
return isVar
case (*ast.IndexExpr): // like X[Y], check X
Expand Down

0 comments on commit 1977096

Please sign in to comment.