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: global variable assignment implicit type conversion error #68264

Closed
deelawn opened this issue Jul 1, 2024 · 5 comments
Closed
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@deelawn
Copy link

deelawn commented Jul 1, 2024

Go version

go1.22.4 darwin/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/Users/dylan/Library/Caches/go-build'
GOENV='/Users/dylan/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/dylan/go/pkg/mod'
GONOPROXY='github.com/deelawn'
GONOSUMDB='github.com/deelawn'
GOOS='darwin'
GOPATH='/Users/dylan/go'
GOPRIVATE='github.com/deelawn'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_amd64'
GOVCS=''
GOVERSION='go1.22.4'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/dylan/deelawn/gnoland/gno2/gno/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/6v/ptrk49k16l32ftg2l8x0q8j40000gn/T/go-build4157790115=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

https://go.dev/play/p/AwgUrKVlv9_Z

package main

import "fmt"

type nat []int

var a, b nat = y()

func y() (nat, []int) {
	return nat{0}, nat{1}
}

func main() {
	fmt.Println(a, b)
}

What did you see happen?

./prog.go:7:5: internal compiler error: unexpected initialization statement: a, b = .autotmp_0, .autotmp_1

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

What did you expect to see?

Expected output of [0] [1], identical to what is output when doing the same assignment to local variables:

package main

import "fmt"

type nat []int

func y() (nat, []int) {
	return nat{0}, nat{1}
}

func main() {
	var a, b nat = y()
	fmt.Println(a, b)
}
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 1, 2024
@thanm thanm added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 1, 2024
@thanm
Copy link
Contributor

thanm commented Jul 1, 2024

Thanks for the report.

Interestingly, this problem appears to have been around for quite some time; I can reproduce it at tip, then in 1.22 all the way back to 1.16 (works ok in 1.15).

@golang/compiler

@dr2chase
Copy link
Contributor

dr2chase commented Jul 1, 2024

I have a nasty suspicion this is something in expand_calls.

@cherrymui
Copy link
Member

Actually, this panics in the frontend
https://go.dev/play/p/AwgUrKVlv9_Z?v=gotip

./prog.go:7:5: internal compiler error: unexpected initialization statement: a, b = .autotmp_0, .autotmp_1

goroutine 1 [running]:
runtime/debug.Stack()
	/usr/local/go/src/runtime/debug/stack.go:26 +0x5e
cmd/compile/internal/base.FatalfAt({0x479e91?, 0x0?}, {0xe4cd0e, 0x27}, {0xc00045b728, 0x1, 0x1})
	/usr/local/go/src/cmd/compile/internal/base/print.go:230 +0x1ea
cmd/compile/internal/staticinit.(*Schedule).tryStaticInit(0xc00045b880, {0xfa51a0, 0xc000437aa0})
	/usr/local/go/src/cmd/compile/internal/staticinit/sched.go:106 +0x1f7
cmd/compile/internal/staticinit.(*Schedule).StaticInit(0xc00045b880, {0xfa51a0, 0xc000437aa0})
	/usr/local/go/src/cmd/compile/internal/staticinit/sched.go:58 +0x26
cmd/compile/internal/pkginit.MakeTask()
	/usr/local/go/src/cmd/compile/internal/pkginit/init.go:99 +0x945
cmd/compile/internal/gc.Main(0xe66fe8)
	/usr/local/go/src/cmd/compile/internal/gc/main.go:244 +0xffd
main.main()
	/usr/local/go/src/cmd/compile/main.go:57 +0xf9

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/596055 mentions this issue: cmd/compile: fix ICE when compiling global a, b = f()

@thanm thanm moved this to In Progress in Go Compiler / Runtime Jul 3, 2024
@thanm thanm added this to the Go1.23 milestone Jul 3, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in Go Compiler / Runtime Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
Development

No branches or pull requests

6 participants