Skip to content

Commit 1977096

Browse files
committed
fix #13: don't follow the postion of the global variable: it clearly is
not a local variable.
1 parent 4ad8bcf commit 1977096

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

exportloopref.go

+3
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,9 @@ func (s *Searcher) isVar(loop ast.Node, expr ast.Expr) bool {
298298
}
299299
switch typed := expr.(type) {
300300
case (*ast.Ident):
301+
if typed.Obj == nil {
302+
return false // global var in another file (ref: #13)
303+
}
301304
_, isVar := vars[typed.Obj.Pos()]
302305
return isVar
303306
case (*ast.IndexExpr): // like X[Y], check X

0 commit comments

Comments
 (0)