diff options
author | Teddy Wing | 2023-05-21 06:18:22 +0200 |
---|---|---|
committer | Teddy Wing | 2023-05-21 06:18:22 +0200 |
commit | 859d89a12cfb3a4b92dc292a43daa0641acf69c3 (patch) | |
tree | 639ec7db5e9fd2e3d8a468ac242976ec57c6177f /defererr.go | |
parent | f18f23bfda632dda6c6ee2fe595e088ac8075378 (diff) | |
download | godefererr-859d89a12cfb3a4b92dc292a43daa0641acf69c3.tar.bz2 |
Add ideas for checking `return`s
Diffstat (limited to 'defererr.go')
-rw-r--r-- | defererr.go | 9 |
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( |