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

Comments

Projects
None yet
5 participants
@rmmh
Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor Author

commented Feb 26, 2018

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

@ysmolsky

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Contributor

commented Feb 27, 2018

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

This comment has been minimized.

Copy link

commented Feb 27, 2018

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

@gopherbot gopherbot closed this in e2b5e60 Feb 28, 2018

@golang golang locked and limited conversation to collaborators Feb 28, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.