Skip to content

Conversation

@maratori
Copy link
Contributor

Previously linter didn't understand that variable is shadowed, and didn't complain about following code (with --allow-error-in-defer enabled). Now it's fixed.

func shadowVariable() (err error) {
	defer func() {
		err := errors.New("xxx")
	}()
}

Also now linter checks real type, not only name error (which can also be shadowed).

@firefart firefart merged commit 34daa66 into firefart:main Jun 25, 2022
@firefart
Copy link
Owner

btw: I made the named error ignore when used in defer now the default and renamed the flag accordingly in v1.0.4. Will update golang-ci once the linter is updated

@maratori maratori deleted the shadow-var branch June 25, 2022 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants