Skip to content

internal compiler error for implicitly instantiated function as argument with lang set to go1.20 when running coverage #68759

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

Closed
msbit opened this issue Aug 7, 2024 · 2 comments

Comments

@msbit
Copy link

msbit commented Aug 7, 2024

Go version

go version go1.22.2 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/tom/Library/Caches/go-build'
GOENV='/Users/tom/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/tom/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/tom/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/local/lib/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/local/lib/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.2'
GCCGO='gccgo'
AR='ar'
CC='/usr/bin/clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/var/folders/_g/kc3wz03n2mb32x9ty7m6sh9m0000gn/T/tmp.zuUgtxE2hE/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 -ffile-prefix-map=/var/folders/_g/kc3wz03n2mb32x9ty7m6sh9m0000gn/T/go-build1647504027=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

go.mod:

module test

go 1.20

main.go:

package main

func A[T any](v T, fn func(T) T) T { return fn(v) }

func B[T any](v T) T { return v }

func main() {
	A(0, B)
}

What did you see happen?

$ go test -cover .
# test
<unknown line number>: internal compiler error: panic: runtime error: invalid memory address or nil pointer dereference

Please file a bug report including a short program that triggers the error.
https://go.dev/issue/new
FAIL	test [build failed]
FAIL

What did you expect to see?

$ go test -cover .
	test		coverage: 0.0% of statements
@msbit msbit changed the title internal compiler error for implicitly instantiated function as argument with lang was set to go1.20 when running coverage internal compiler error for implicitly instantiated function as argument with lang set to go1.20 when running coverage Aug 7, 2024
@seankhliao
Copy link
Member

1.22.5 reports an error, not a panic:

./main.go:8:7: implicitly instantiated function as argument requires go1.21 or later (-lang was set to go1.20; check go.mod)
FAIL go.seankhliao.com/testrepo0743 [build failed]

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Aug 7, 2024
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

3 participants