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: shape types have no methods #55134

Closed
amirdlt opened this issue Sep 18, 2022 · 10 comments
Closed

cmd/compile: internal compiler error: shape types have no methods #55134

amirdlt opened this issue Sep 18, 2022 · 10 comments

Comments

@amirdlt
Copy link

amirdlt commented Sep 18, 2022

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

$ go version
go version go1.19.1 windows/amd64

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
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\AmirDLT\AppData\Local\go-build
set GOENV=C:\Users\AmirDLT\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\AmirDLT\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\AmirDLT\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Users\AmirDLT\sdk\go1.18
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Users\AmirDLT\sdk\go1.18\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.18
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\AmirDLT\GolandProjects\flex\go.mod
set GOWORK=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\AmirDLT\AppData\Local\Temp\go-build2421505650=/tmp/go-build -gno-record-gcc-switches

What did you do?

I assign a function argument of type func(any) any into a map[string]any as a value e.g. m["func"] = func(any) any {return nil}, then read the map and
assert type then use it, It leads to an internal compiler error in the line I wanted to call the function.
The situation that it has happened is a bit complicated, I've pushed my code on a github project linked
below. You can see the issue by run the main.go file, if you want to get more info.
Btw I have used generics which can caused this issue probably.

Handler[SI ServerInjector, B any] func(injector *HandlerInjector[SI, B]) HandlerResult
handler = w.(func(any) any)(handler).(Handler[SI, B]) --> this line caused the issue

project: https://github.com/amirdlt/flex

What did you expect to see?

Program should be compiled and run successfully

What did you see instead?

# github.com/amirdlt/flex
.\core\middleware.go:142:32: internal compiler error: shape types have no methods core.Handler[go.shape.struct { Username string; ServerBaseInjector = github.com/amirdlt/flex/core.ServerBaseInjector[""._ServerInjector] }_0,go.shape.interface {}_1]

Please file a bug report including a short program that triggers the error.
https://go.dev/issue/new
@mvdan
Copy link
Member

mvdan commented Sep 18, 2022

1.18 is an outdated version; please try 1.18.5 or 1.19.1.

@mvdan mvdan added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Sep 18, 2022
@amirdlt
Copy link
Author

amirdlt commented Sep 18, 2022

I've tested it with go 1.19.1 too, the issue persists.

@Fahad1410

This comment was marked as duplicate.

@amirdlt
Copy link
Author

amirdlt commented Sep 18, 2022

1.18 is an outdated version; please try 1.18.5 or 1.19.1.

I did it, the issue persists.

@amirdlt
Copy link
Author

amirdlt commented Sep 19, 2022

1.18 is an outdated version; please try 1.18.5 or 1.19.1.

I've tested it with go 1.19.1 too, the issue persists.

@bcmills bcmills removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Sep 19, 2022
@cherrymui cherrymui changed the title Internal compiler error cmd/compile: internal compiler error: shape types have no methods Sep 19, 2022
@cherrymui
Copy link
Member

cherrymui commented Sep 19, 2022

This seems fixed at tip. github.com/amirdlt/flex builds successfully. I think we can close this. Feel free to reopen if it doesn't.

Maybe this is a dup of another issue, but I'm not sure which one. There are a few "shape types have no methods" issues (https://github.com/golang/go/issues?q=is%3Aissue+%22shape+types+have+no+methods%22). It seems unified IR fixes this (it fails to build with GOEXPERIMENT=nounified).
cc @mdempsky @cuonglm

@cuonglm
Copy link
Member

cuonglm commented Sep 20, 2022

FYI, this does not seem to be a dup of any existed issue, the compiler still crashes with GOEXPERIMENT=nounified at current tip f8c659b

@amirdlt amirdlt changed the title cmd/compile: internal compiler error: shape types have no methods runtime/panic: internal compiler error in runtime: shape types have no methods Sep 20, 2022
@amirdlt
Copy link
Author

amirdlt commented Sep 20, 2022

This seems fixed at tip. github.com/amirdlt/flex builds successfully. I think we can close this. Feel free to reopen if it doesn't.

Maybe this is a dup of another issue, but I'm not sure which one. There are a few "shape types have no methods" issues (https://github.com/golang/go/issues?q=is%3Aissue+%22shape+types+have+no+methods%22). It seems unified IR fixes this (it fails to build with GOEXPERIMENT=nounified). cc @mdempsky @cuonglm

It was not a compile error, It compiled successfully, I get an internal compiler error at runtime not compile time.

@amirdlt amirdlt changed the title runtime/panic: internal compiler error in runtime: shape types have no methods runtime: internal compiler error in runtime: shape types have no methods Sep 20, 2022
@cherrymui
Copy link
Member

cherrymui commented Sep 20, 2022

The text "internal compiler error" says clearly it is a compile time error.

@cherrymui cherrymui changed the title runtime: internal compiler error in runtime: shape types have no methods cmd/compile: internal compiler error: shape types have no methods Sep 20, 2022
@amirdlt
Copy link
Author

amirdlt commented Sep 21, 2022

The text "internal compiler error" says clearly it is a compile time error.

I'm sorry, I've made a dumbly mistake. You're right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants