You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\SLADE\AppData\Local\go-build
set GOENV=C:\Users\SLADE\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\SLADE\.gopath\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\SLADE\.gopath
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=D:\Programs\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=D:\Programs\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.19.4
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=D:\Projects\Go\issue\go.mod
set GOWORK=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\SLADE\AppData\Local\Temp\go-build583418767=/tmp/go-build -gno-record-gcc-switches
But if I move all the code except main-func to a package, e.g. foo, the code stops working.
main.go
package main
import (
"issue/foo"
)
func main() {
println(foo.Chain(foo.Foo()))
}
foo/foo.go
package foo
type Func func() error
func Chain(funcs ...Func) error {
for _, f := range funcs {
if err := f(); err != nil {
return err
}
}
return nil
}
func Foo() Func {
return bar[string]{}.Validate
}
type bar[T any] struct{}
func (v bar[T]) Validate() error {
return nil
}
go.mod
module issue
go 1.19
What did you expect to see?
Is compiles successfully
What did you see instead?
.\main.go:8:27: internal compiler error: 'main': Value live at entry. It shouldn't be. func main, node foo..rcvr1, value nil
Please file a bug report including a short program that triggers the error.
https://go.dev/issue/new
The text was updated successfully, but these errors were encountered:
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
This single-package version works just fine.
But if I move all the code except
main
-func to a package, e.g.foo
, the code stops working.main.go
foo/foo.go
go.mod
What did you expect to see?
Is compiles successfully
What did you see instead?
The text was updated successfully, but these errors were encountered: