diff options
author | Teddy Wing | 2023-05-24 18:37:01 +0200 |
---|---|---|
committer | Teddy Wing | 2023-05-24 18:39:32 +0200 |
commit | c9a17ef7d9501d9a389f069f168723330b865b37 (patch) | |
tree | e2d23b115f70190391814e55a5e254873870efa6 | |
parent | a2b4aadc3c35d06335aced394a2f0e03bff95e18 (diff) | |
download | godefererr-c9a17ef7d9501d9a389f069f168723330b865b37.tar.bz2 |
Change `isFirstErrorDeferEndPosSet()` to `deferAssignsError()`
The previous function didn't make enough sense without the context of
when `firstErrorDeferEndPos` is set. Use a different function named for
what we actually want to know.
-rw-r--r-- | defererr.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/defererr.go b/defererr.go index d21b0b6..54cedcf 100644 --- a/defererr.go +++ b/defererr.go @@ -50,8 +50,8 @@ func (s *functionState) setFirstErrorDeferEndPos(pos token.Pos) { s.firstErrorDeferEndPos = pos } -func (s *functionState) isFirstErrorDeferEndPosSet() bool { - return s.firstErrorDeferEndPos != -1 +func (s *functionState) deferAssignsError() bool { + return s.deferErrorVar != nil } func checkFunctions(pass *analysis.Pass, node ast.Node) { @@ -143,7 +143,9 @@ func checkFunctions(pass *analysis.Pass, node ast.Node) { fmt.Printf("fState: %#v\n", fState) - if !fState.isFirstErrorDeferEndPosSet() { + // Stop if the `defer` closure does not assign to an error + // variable. + if !fState.deferAssignsError() { return true } |