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

cmd/vet: return analysis fails with type-switching and panic() #24140

Closed
rmmh opened this issue Feb 26, 2018 · 4 comments
Closed

cmd/vet: return analysis fails with type-switching and panic() #24140

rmmh opened this issue Feb 26, 2018 · 4 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Milestone

Comments

@rmmh
Copy link
Contributor

rmmh commented Feb 26, 2018

What version of Go are you using (go version)?

go version devel +0c471dfae2 Mon Feb 26 20:22:06 2018 +0000 linux/amd64

Does this issue reproduce with the latest release?

No-- this is in changes after 1.10.

What did you do?

Given a.go:

package kubernetes

func DeepCopyJSONValue(x interface{}) interface{} {
        switch x := x.(type) {
        case []interface{}:
                clone := make([]interface{}, len(x))
                for i, v := range x {
                        clone[i] = v
                }
                return clone
        default:
                panic("cannot deep copy")
        }
}
$ go vet a.go
# command-line-arguments
./a.go:14:1: missing return
vet: typecheck failures

What did you expect to see?

No typecheck failures.

@rmmh
Copy link
Contributor Author

rmmh commented Feb 26, 2018

With go vet becoming part of go test, parsing & typechecking the go corpus might be a good test.

@ianlancetaylor ianlancetaylor added this to the Go1.11 milestone Feb 27, 2018
@ianlancetaylor ianlancetaylor added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker labels Feb 27, 2018
@ysmolski
Copy link
Member

ysmolski commented Feb 27, 2018

This happened after the 99843e2

% go version ; go vet a.go
go version devel +cbfda7f892 Mon Feb 26 18:32:38 2018 +0000 darwin/amd64
% go version ; go vet a.go
go version devel +99843e22e8 Mon Feb 26 18:46:26 2018 +0000 darwin/amd64
# command-line-arguments
./a.go:14:1: missing return
vet: typecheck failures

/cc @griesemer

@griesemer griesemer self-assigned this Feb 27, 2018
@griesemer
Copy link
Contributor

Thanks, @ysmolsky for tracking down the offending change; this made it easy to identify the problem. I've got the fix (minor oversight in 99843e2) and will have a CL later today.

@gopherbot
Copy link

Change https://golang.org/cl/97535 mentions this issue: go/types: fix incorrect context when type-checking interfaces

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Projects
None yet
Development

No branches or pull requests

5 participants