aboutsummaryrefslogtreecommitdiffstats
path: root/testdata/signature.go
AgeCommit message (Collapse)Author
2023-05-26Add license (GNU GPLv3+)v0.0.1Teddy Wing
2023-05-25shouldDeclareErrInSignature: Add note about variable declaration lineTeddy Wing
When I was first coming up with ideas for the project, I thought that this line is one I might need to report a diagnostic for, but since the compiler will catch it, we don't need to bother.
2023-05-25Report missing signature declaration with multiple return valuesTeddy Wing
The previous message which reported when a function's return signature didn't declare an error variable didn't work for functions with multiple return values. I thought about extending it and coming up with generated variable names for the non-error types to be able to support automatic fixing, but this idea ended up being too complicated. Also, I didn't like the idea of an automated fixer coming up with generated variable names, because you'd need to manually rename them anyway. That kind of defeats the purpose of it being automated. Instead, change the diagnostic message to only refer to the error variable and recommend what the declared variable name should be based on the identifier the error was assigned to in the defer. Modify our multiple return value test functions according to this new approach.
2023-05-25checkFunctions: Keep `continue` in return value loopTeddy Wing
Looks like the return value type is always an `*ast.Ident`. Use `continue` instead of `return true` to be more tolerant of unexpected values.
2023-05-23Idea about multiple return valuesTeddy Wing
2023-05-23Add tests with multiple return valuesTeddy Wing
Don't pass yet as we currently only suggest `(errorVar error)` as the return signature.
2023-05-21Report function signature declaration using variable name other than errTeddy Wing
I had previously hard-coded the variable name "err" as the recommended name declaration in the function signature for simplicity. Now, use the name assigned in the `defer` instead, which is more correct.
2023-05-21Clarify name of `returnsOtherVariable` testTeddy Wing
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-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-20Find function signature return value namesTeddy Wing
And add a test function that does have named returned values.
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.