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

Comment From: gabyhelp

Related Issues and Documentation

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

Comment From: seankhliao

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]