aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2023-05-21Check whether returned name matches defer error nameTeddy Wing
Ensure the name of the returned error variable matches the name of the error variable assigned in the `defer` statement.
2023-05-21Inspect return value looking at type and nameTeddy Wing
Want to check that the `return` statement uses the same variable used in the `defer` closure. Start inspecting the values to figure out how we can narrow that down. Add a test case for a "good" assignment of a returned error in `defer`.
2023-05-21Get type information from `return` statement valuesTeddy Wing
2023-05-21Explore inspecting `return` statements for error valuesTeddy Wing
2023-05-21Add skeleton for checking `return` statements after `defer` closuresTeddy Wing
2023-05-21Correctly `setFirstErrorDeferEndPos` for `doesDeclareErrInSignature`Teddy Wing
Since `ident.Obj.Decl` is a `*ast.ValueSpec` in `shouldDeclareErrInSignature` but a `*ast.Field` in `doesDeclareErrInSignature`, we need to handle both declaration types. Turn the value into an `ast.Node`, which covers both, and use that to determine whether the variable is declared in the closure.
2023-05-21Working out why doesDeclareErrInSignature doesn't get far in assign loopTeddy Wing
We were looking for a `*ast.ValueSpec`, but it looks like when `err` is declared in the function signature, the type is `*ast.Field`.
2023-05-21Print the current function for easier debuggingTeddy Wing
Show me which function the debug print statements belong to.
2023-05-21Try to store the end position of the first defer closure with errorTeddy Wing
The idea is to store the end position of the first defer closure that assigns an error variable from the outer scope. Then, we can check the `return` statements in the rest of the function after that position to ensure they use the error variable.
2023-05-21Update `firstDeferEndPos` nameTeddy Wing
Clarify intended contents.
2023-05-21Add ideas for checking `return`sTeddy Wing
2023-05-21Idea for checking `return`sTeddy Wing
2023-05-21Next step to check usage of error variable in returnTeddy Wing
2023-05-21Move error variable GenDecl check to functionTeddy Wing
Give the check a name.
2023-05-21Ignore errors declared using GenDecl inside defer closureTeddy Wing
We don't want to report error variables that were declared inside the closure, as those don't depend on the outside scope.
2023-05-21Idea to move defer func check to a separate functionTeddy Wing
2023-05-21Move function `ast.Inspect` to new functionTeddy Wing
Give it a name.
2023-05-21Move defer closure `ast.Inspect` to a separate functionTeddy Wing
Trying to make this easier to read.
2023-05-21Add test to ensure error vars declared in defer closure are not reportedTeddy Wing
2023-05-20Report when error declaration in signature is neededTeddy Wing
While looking at the assignments in the `defer`, if we encounter an `error`-type assignment, emit a diagnostic if the error named in the lhs of the assignment is not present in the return signature's names. Not sure if this makes sense to me yet. I probably only want to report a problem for a non-declare assignment of an error value when the error type in the return signature is _not_ named at all.
2023-05-20Get error variable names from type loopTeddy Wing
Store the index where we find the `error` type in the function signature's return list so we can use it later to get the corresponding variable names, if any.
2023-05-20Find function signature return value namesTeddy Wing
And add a test function that does have named returned values.
2023-05-19Check for error types in assignments in `defer`Teddy Wing
2023-05-19Work out how to get type name of assignments in `defer`Teddy Wing
2023-05-18Find assignments in defer closureTeddy Wing
2023-05-18Use `FuncDecl` instead of `FuncType`Teddy Wing
I didn't read the docs carefully, it turns out `FuncType` only gives us the signature. If we want access to the function body as well to be able to walk its AST, we need a `FuncDecl`.
2023-05-18Ideas for walking functions first instead of `defer`s firstTeddy Wing
I was having a hard time figuring out how to get the function where a `defer` occurs from the defer, so I decided to look at all functions first instead, and find out if they contain `defer`s.
2023-05-18Ideas for an analyser for returning errors from deferTeddy Wing
Still working out how to traverse the AST to be able to see the objects I need.
2023-05-16Add Idea.txtTeddy Wing
Idea for a new linter for ensuring errors are returned from `defer` closures.