Age | Commit message (Collapse) | Author |
|
|
|
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.
|
|
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.
|
|
Looks like the return value type is always an `*ast.Ident`. Use
`continue` instead of `return true` to be more tolerant of unexpected
values.
|
|
|
|
Don't pass yet as we currently only suggest `(errorVar error)` as the
return signature.
|
|
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.
|
|
|
|
Ensure the name of the returned error variable matches the name of the
error variable assigned in the `defer` statement.
|
|
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`.
|
|
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.
|
|
And add a test function that does have named returned values.
|
|
Still working out how to traverse the AST to be able to see the objects
I need.
|