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/compile: internal compiler error: want STRUCT, but have PTR #48056

Closed
korzhao opened this issue Aug 30, 2021 · 1 comment
Closed

cmd/compile: internal compiler error: want STRUCT, but have PTR #48056

korzhao opened this issue Aug 30, 2021 · 1 comment

Comments

@korzhao
Copy link
Contributor

@korzhao korzhao commented Aug 30, 2021

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

$ go version
go tip go1.18-a16ac45570 

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
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/kezhao/Library/Caches/go-build"
GOENV="/Users/kezhao/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/kezhao/go/pkg/mod"
GONOPROXY="git.code.oa.com,git.woa.com"
GONOSUMDB="git.code.oa.com,git.woa.com"
GOOS="darwin"
GOPATH="/Users/kezhao/go"
GOPRIVATE="git.code.oa.com,git.woa.com"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/kezhao/google/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/kezhao/google/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="devel go1.18-56c3856d52 Mon Aug 30 02:40:46 2021 +0000"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/kezhao/go/src/apnstest/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/2g/yv3ln7wj5vbdtwfj0js10krh0000gn/T/go-build3452127800=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

package main

type B[T any] interface {
	Work()
}
type BImpl[T any] struct{}
func (b *BImpl[T]) Work() {
}

type A[T any] struct {
	B[T]
}
func f[T any]() {
	s := &A[T]{
		&BImpl[T]{},
	}
	s.Work()
}
func main() {
	f[string]()
}

What did you expect to see?

no error

What did you see instead?

./main.go:17:2: internal compiler error: want STRUCT, but have *A[main.T₅]

goroutine 1 [running]:
runtime/debug.Stack()
	/Users/kezhao/google/go/src/runtime/debug/stack.go:24 +0x65
cmd/compile/internal/base.FatalfAt({0x1a51330, 0x0}, {0x18fb511, 0x14}, {0xc00081ea48, 0x2, 0x2})
	/Users/kezhao/google/go/src/cmd/compile/internal/base/print.go:227 +0x154
cmd/compile/internal/base.Fatalf(...)
	/Users/kezhao/google/go/src/cmd/compile/internal/base/print.go:196
cmd/compile/internal/types.(*Type).wantEtype(...)
	/Users/kezhao/google/go/src/cmd/compile/internal/types/type.go:925
cmd/compile/internal/types.(*Type).Fields(0xc0008cea10)
	/Users/kezhao/google/go/src/cmd/compile/internal/types/type.go:1040 +0x86
cmd/compile/internal/types.(*Type).Field(...)
	/Users/kezhao/google/go/src/cmd/compile/internal/types/type.go:1046
cmd/compile/internal/noder.(*irgen).selectorExpr(0xc00069ae00, {0x586a80, 0xc0}, {0x1a51380, 0xc000539880}, 0xc000373350)
	/Users/kezhao/google/go/src/cmd/compile/internal/noder/expr.go:275 +0x1285
cmd/compile/internal/noder.(*irgen).expr0(0xc00069ae00, {0x1a51380, 0xc000539880}, {0x1a524c8, 0xc000373350})
	/Users/kezhao/google/go/src/cmd/compile/internal/noder/expr.go:197 +0x75b
cmd/compile/internal/noder.(*irgen).expr(0xc00069ae00, {0x1a524c8, 0xc000373350})
	/Users/kezhao/google/go/src/cmd/compile/internal/noder/expr.go:80 +0x610
cmd/compile/internal/noder.(*irgen).expr0(0xc00069ae00, {0x1a513f8, 0x0}, {0x1a51fe8, 0xc0000bfa00})
	/Users/kezhao/google/go/src/cmd/compile/internal/noder/expr.go:115 +0x166
cmd/compile/internal/noder.(*irgen).expr(0xc00069ae00, {0x1a51fe8, 0xc0000bfa00})
	/Users/kezhao/google/go/src/cmd/compile/internal/noder/expr.go:80 +0x610
cmd/compile/internal/noder.(*irgen).stmt(0xc00069ae00, {0x1a52168, 0xc00037bfe0})
	/Users/kezhao/google/go/src/cmd/compile/internal/noder/stmt.go:40 +0x875
cmd/compile/internal/noder.(*irgen).stmts(0xc00085f730, {0xc0003ce000, 0x2, 0x27a53f0})
	/Users/kezhao/google/go/src/cmd/compile/internal/noder/stmt.go:19 +0xaf
cmd/compile/internal/noder.(*irgen).funcBody(0xc00069ae00, 0xc000855e40, 0xc000883a88, 0xc0000bf8c0, 0xc0000bf900)
	/Users/kezhao/google/go/src/cmd/compile/internal/noder/func.go:45 +0x25f
cmd/compile/internal/noder.(*irgen).funcDecl.func1()
	/Users/kezhao/google/go/src/cmd/compile/internal/noder/decl.go:124 +0x68
cmd/compile/internal/noder.(*irgen).generate(0xc00069ae00, {0xc000372ea0, 0x6, 0x0})
	/Users/kezhao/google/go/src/cmd/compile/internal/noder/irgen.go:265 +0x18b
cmd/compile/internal/noder.check2({0xc000372ea0, 0x6, 0x6})
	/Users/kezhao/google/go/src/cmd/compile/internal/noder/irgen.go:92 +0x177
cmd/compile/internal/noder.LoadPackage({0xc0000c4110, 0x6, 0x50})
	/Users/kezhao/google/go/src/cmd/compile/internal/noder/noder.go:90 +0x335
cmd/compile/internal/gc.Main(0x191e230)
	/Users/kezhao/google/go/src/cmd/compile/internal/gc/main.go:190 +0xaf3
main.main()
	/Users/kezhao/google/go/src/cmd/compile/main.go:55 +0xdd
@gopherbot
Copy link

@gopherbot gopherbot commented Aug 30, 2021

Change https://golang.org/cl/346049 mentions this issue: cmd/compile: fix error when revcType is ptr in selectorExpr

Loading

@korzhao korzhao changed the title cmd/compile: internal compiler error: want STRUCT, but have *A cmd/compile: internal compiler error: want STRUCT, but have PTR Aug 30, 2021
@gopherbot gopherbot closed this in b602dae Aug 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants