aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2023-05-21 06:18:22 +0200
committerTeddy Wing2023-05-21 06:18:22 +0200
commit859d89a12cfb3a4b92dc292a43daa0641acf69c3 (patch)
tree639ec7db5e9fd2e3d8a468ac242976ec57c6177f
parentf18f23bfda632dda6c6ee2fe595e088ac8075378 (diff)
downloadgodefererr-859d89a12cfb3a4b92dc292a43daa0641acf69c3.tar.bz2
Add ideas for checking `return`s
-rw-r--r--defererr.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/defererr.go b/defererr.go
index e7df464..837fa90 100644
--- a/defererr.go
+++ b/defererr.go
@@ -71,6 +71,15 @@ func checkFunctions(pass *analysis.Pass, node ast.Node) {
}
errorReturnField := funcDecl.Type.Results.List[errorReturnIndex]
+ // Idea: Set this to the end token.Pos of the first `defer`
+ // closure. Look for `return`s after that in funcDecl.Body and
+ // ensure they include the error variable.
+ firstDeferEndPos := -1
+
+ // Is it possible to generalise this to other types, and look for
+ // anything set in `defer` with the same type as a result in the
+ // return signature?
+
// TODO: Move to checkDeferFunc()
// Should we make this an ast.Visitor to store some state for `return` checking?
ast.Inspect(