go: cmd/compile: internal compiler error: panic: interface conversion: ir.Node is *ir.BasicLit, not *ir.ConstExpr

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

$ go version
go version go1.20 darwin/arm64

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=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/r/Library/Caches/go-build"
GOENV="/Users/r/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/r/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/r/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/Users/r/sdk/go1.20"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/r/sdk/go1.20/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.20"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/r/workspace/testcode/testinline/bug2.1/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 arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/j_/rq9ph2cd3h50w468sgv34lwh0000gn/T/go-build2923148267=/tmp/go-build -gno-record-gcc-switches -fno-common"
GOROOT/bin/go version: go version go1.20 darwin/arm64
GOROOT/bin/go tool compile -V: compile version go1.20
uname -v: Darwin Kernel Version 22.2.0: Fri Nov 11 02:03:51 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T6000
ProductName:		macOS
ProductVersion:		13.1
BuildVersion:		22C65
lldb --version: lldb-1400.0.38.17
Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51)

What did you do?

go.mod:

module foo

go 1.20

pkg/a.go:

package pkg

func Assert(msgAndArgs ...any) {
}

func Run() int {
        Assert("%v")
        return 0
}

func Run2() int {
        return Run()
}

b.go:

package main

import "foo/pkg"

var A = pkg.Run2()

func main() {
}

GOEXPERIMENT=nounified go1.20 build ./b.go

What did you expect to see?

Build successfully.

What did you see instead?

# command-line-arguments
./b.go:5:5: internal compiler error: panic: interface conversion: ir.Node is *ir.BasicLit, not *ir.ConstExpr

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

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 16 (12 by maintainers)

Commits related to this issue

Most upvoted comments

do you set GOEXPERIMENT=nounified in your go build?

Unfortunately yes, we have some codegen based tooling that’s seeing huge build time regression due to almost 10x regression in calling gcexportdata.Read when we do not set that.

Will do. We do have plans to migrate that codegen toolchain not rely on gcexportdata before 1.21 is out but we’ll get back to you soon with some repro and profile after further investigation.