Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

respect variable shadowing and type aliasing #10

Merged
merged 2 commits into from Jun 25, 2022
Merged

respect variable shadowing and type aliasing #10

merged 2 commits into from Jun 25, 2022

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).

analyzer/analyzer.go Outdated Show resolved Hide resolved
@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.

None yet

2 participants