Closed as not planned
Closed as not planned
Description
What version of Go are you using (go version
)?
$ go version go version go1.21.1 darwin/arm64
Does this issue reproduce with the latest release?
NO
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GO111MODULE='on' GOARCH='arm64' GOBIN='' GOCACHE='/Users/godot/Library/Caches/go-build' GOENV='/Users/godot/Library/Application Support/go/env' GOEXE='' GOEXPERIMENT='' GOFLAGS='' GOHOSTARCH='arm64' GOHOSTOS='darwin' GOINSECURE='' GOMODCACHE='/Users/godot/go/pkg/mod' GONOPROXY='' GONOSUMDB='' GOOS='darwin' GOPATH='/Users/godot/go' GOPRIVATE='github.com/channel-io/*' GOPROXY='https://proxy.golang.org,direct' GOROOT='/usr/local/go' GOSUMDB='sum.golang.org' GOTMPDIR='' GOTOOLCHAIN='auto' GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64' GOVCS='' GOVERSION='go1.21.1' GCCGO='gccgo' AR='ar' CC='clang' CXX='clang++' CGO_ENABLED='1' GOMOD='/Users/godot/Desktop/WORK/DEV/chx-backend/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/jx/_3jk95_s41g4q3q50mhll7th0000gn/T/go-build1234621002=/tmp/go-build -gno-record-gcc-switches -fno-common'
What did you do?
I tried to compile my project (that used to compile successfully with Go 1.20) but I got an error.
I made a function getting a parameter with generic interface type.
// BoilerModel is generated by sqlboiler - v4.15
func TestFunction[D sqlrepo.DomainModel, B sqlrepo.BoilerModel](
repo sqlrepo.SQLRepo[D, B],
) {}
Then I called that function like this.
// models.Test is generated by sqlboiler - v4.15
type testRepo struct {
sqlrepo.SQLRepo[*model.Test, *models.Test]
}
func (repo *testRepo) ErrorFunction() {
TestFunction(repo.SQLRepo)
}
Result of build is
cannot infer B
But go 1.20 builds that code well.
And why only B cannot be inferred?
https://go.dev/play/p/VxOg1KSvJdz
This is playgroud to reproduce that error but it raises error "cannot infer D" not B.
What did you expect to see?
no error as it is with go 1.20
What did you see instead?
cannot infer B