Skip to content

cmd/compile: global variable assignment implicit type conversion error #68264

@deelawn

Description

@deelawn

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)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions