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

Report unchecked type-assertion when returning value and when passing it to other func #224

Open
leonklingele opened this issue Jan 29, 2023 · 1 comment · May be fixed by #246
Open

Report unchecked type-assertion when returning value and when passing it to other func #224

leonklingele opened this issue Jan 29, 2023 · 1 comment · May be fixed by #246

Comments

@leonklingele
Copy link

Two false negatives here when using the -asserts flag:

package main

func main() {
	var i interface{} = "hello"

	_ = handleInterface(i)

	handleString(i.(string)) // This should be reported but isn't
}

func handleInterface(i interface{}) string {
	return i.(string) // This should be reported but isn't
}

func handleString(s string) {}
@leonklingele
Copy link
Author

Also, this is not caught:

if i.(string) == "hello" {
    ..
}

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

Successfully merging a pull request may close this issue.

2 participants