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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
unused: false positive involving unnamed struct types, named struct types and implicit conversions #810
Labels
Comments
Does this reproduce with the latest staticcheck? |
Yes, I get the following output with
|
Simpler reproducer:
the issue seems to be caused by the implicit conversion to the unnamed struct type in |
dominikh
changed the title
unused: type declared inside function and used in struct literal
unused: false positive involving unnamed struct types, named struct types and implicit conversions
Aug 12, 2020
I can confirm (found using package main
import (
"fmt"
)
type someStruct struct {
parentField struct {
n int
}
}
type someStruct2 struct {
n int
}
func main() {
x := someStruct{
parentField: someStruct2{n: 1},
}
fmt.Println(x)
} Error:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I discovered this while using the
unused
linter ingolangci-lint
. I hope I found the right place to report this issue. 馃Here's some code that reproduces it:
Running
./golangci-lint run unused_test.go
results inunused_test.go:14:7: type `temp` is unused (unused)
.The text was updated successfully, but these errors were encountered: