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

SA4006: build tags and control flow #787

Open
dominikh opened this issue Jun 15, 2020 · 0 comments
Open

SA4006: build tags and control flow #787

dominikh opened this issue Jun 15, 2020 · 0 comments

Comments

@dominikh
Copy link
Owner

The latest entry in our "build tags hate us" saga: SA4006.

func gen() int { return 42 }
func die() { panic("good bye") }

func Fn() {
	x := gen()
	println(x)
	x = gen()
	die()
	println(x)
}

we flag the second assignment to x here, because we recognize that control flow doesn't continue after die gets called. Things get problematic when die turns into feature that is only implemented on some OSs and panics unconditionally on others thanks to build tags. Now we flag an assignment that is only conditionally unused, depending on the build tags in use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant