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: unexpected typecheck failures about "no field or method" #29883

Closed
fatedier opened this issue Jan 23, 2019 · 0 comments
Closed

cmd/vet: unexpected typecheck failures about "no field or method" #29883

fatedier opened this issue Jan 23, 2019 · 0 comments

Comments

@fatedier
Copy link

fatedier commented Jan 23, 2019

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

$ go version
go1.11.4 and go1.12beta2

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/fate/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/fate/local/go_projects"
GOPROXY=""
GORACE=""
GOROOT="/Users/fate/.gvm/gos/go1.11.4"
GOTMPDIR=""
GOTOOLDIR="/Users/fate/.gvm/gos/go1.11.4/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/gx/5yxhg27n2n1c_blprt6c1_lm0000gn/T/go-build865449761=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

go vet report an error message but go build success.

Code on play.golang.org https://play.golang.org/p/fyn_dxhLQJC to reproduce the problem.

package main

import "fmt"

type A interface {
	Print()
	Print2()
}

type a struct {
}

func (a *a) Print() {
	fmt.Println("a")
}

func (a *a) Print2() {
	fmt.Println("a2")
}

type B struct {
	A
}

type C *B

func main() {
	b := &B{
		A: &a{},
	}
	test(b)
}

func test(c C) {
	c.Print()
	c.Print2()
}

What did you expect to see?

No typecheck failures.

What did you see instead?

When using go1.11.4:

# command-line-arguments
./a.go:35:4: invalid operation: c (variable of type C) has no field or method Print
./a.go:36:4: invalid operation: c (variable of type C) has no field or method Print2
vet: typecheck failures

When using go1.12beta2

# command-line-arguments
vet: ./a.go:35:4: c.Print undefined (type C has no field or method Print)
@golang golang locked and limited conversation to collaborators Jan 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants