From 3f4e4cf94596eaae380385d81f9a629fbee0eb7d Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 20 May 2023 21:31:05 +0200 Subject: Report when error declaration in signature is needed 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. --- testdata/signature.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'testdata') diff --git a/testdata/signature.go b/testdata/signature.go index 6fc15fc..d780240 100644 --- a/testdata/signature.go +++ b/testdata/signature.go @@ -2,7 +2,7 @@ package main import "errors" -func shouldDeclareErrInSignature() error { // want "return signature should be '(err error)'" +func shouldDeclareErrInSignature() error { // want "return signature should be '\\(err error\\)'" var err error // Should use variable declared in signature err = nil -- cgit v1.2.3