Skip to content

Commit

Permalink
Explain getRootIdent/ObjectOf/Pos check
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelUrman committed May 29, 2024
1 parent 0e13d06 commit 69e9ae1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ func run(pass *analysis.Pass) (interface{}, error) {
break
}

// allow assignment to non-pointer children of values defined within the loop
if lhs := getRootIdent(pass, assignStmt.Lhs[0]); lhs != nil {
if obj := pass.TypesInfo.ObjectOf(lhs); obj != nil {
if obj.Pos() >= body.Pos() && obj.Pos() < body.End() {
continue
continue // definition is within the loop
}
}
}
Expand Down

0 comments on commit 69e9ae1

Please sign in to comment.