Closed
Description
What version of Go are you using (go version
)?
$ go version go version go1.20.1 linux/amd64
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 10:52 $ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/zapo/.cache/go-build" GOENV="/home/zapo/.config/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/home/zapo/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/zapo/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/home/zapo/.asdf/installs/golang/1.20.1/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/home/zapo/.asdf/installs/golang/1.20.1/go/pkg/tool/linux_amd64" GOVCS="" GOVERSION="go1.20.1" GCCGO="gccgo" GOAMD64="v1" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/home/zapo/src/test/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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2227726188=/tmp/go-build -gno-record-gcc-switches"
What did you do?
./pkg/pkg.go
package pkg
func Start() interface{ Stop() } {
return new(Stopper)
}
type Stopper struct{}
func (s *Stopper) Stop() {}
./main.go
package main
import "test/pkg"
func main() {
stop := start()
defer stop()
}
func start() func() {
return pkg.Start().Stop
}
What did you expect to see?
Successful build.
What did you see instead?
./pkg/pkg.go:3:6: internal compiler error: assertion failed
I can fix it by allocating the return of Start()
or using a named interface, or avoiding to return the pointer to Stop interface by chaning start() to:
func start() func() {
return func() { pkg.Start().Stop() }
}
Also I couldn't reproduce it if merging in the same package.