Skip to content

cmd/compile: interface conversion with generics reports "types from different scopes" [1.18 backport]  #53883

@fractalqb

Description

@fractalqb

What version of Go are you using (go version)?

$ go version
go version go1.18.4 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
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/USER/.cache/go-build"
GOENV="/home/USER/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/USER/gows/pkg/mod"
GONOPROXY="athome.fractalqb.de"
GONOSUMDB="athome.fractalqb.de"
GOOS="linux"
GOPATH="/home/USER/gows"
GOPRIVATE="athome.fractalqb.de"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/USER/bin/go1.18.4"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/USER/bin/go1.18.4/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.4"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/USER/gows/src/git.fractalqb.de/proto/different-scopes-1.18.3/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build131321195=/tmp/go-build -gno-record-gcc-switches"

What did you do?

  1. Compile this code
package main

import (
	"fmt"

	"github.com/fractalqb/change"
	"github.com/fractalqb/change/chgsql"
)

var id change.Val[uint64]

func main() {
	v := chgsql.Nullable[uint64](&id, 0)
	fmt.Println(v)
}
  1. Run the program
$ ./different-scopes
panic: interface conversion: change.Changeable[go.shape.uint64_0] is *change.Val[uint64], not *change.Val[uint64] (types from different scopes)

goroutine 1 [running]:
github.com/fractalqb/change/chgsql.Nullable[...](...)
	/home/USERgows/pkg/mod/github.com/fractalqb/change@v0.4.1/chgsql/type.go:27
main.main()
	/home/USER/gows/src/git.fractalqb.de/proto/different-scopes-1.18.3/main.go:16 +0x2e

What did you expect to see?

When running the program I expect the output to be: <nil>

When compiling and running with Go 1.18.2 it works as expected. Please also read my remarks on #52027

What did you see instead?

As already mentioned above. Running the Program (compiled with 1.8.4) gives me the output:

panic: interface conversion: change.Changeable[go.shape.uint64_0] is *change.Val[uint64], not *change.Val[uint64] (types from different scopes)

goroutine 1 [running]:
github.com/fractalqb/change/chgsql.Nullable[...](...)
	/home/USERgows/pkg/mod/github.com/fractalqb/change@v0.4.1/chgsql/type.go:27
main.main()
	/home/USER/gows/src/git.fractalqb.de/proto/different-scopes-1.18.3/main.go:16 +0x2e

Metadata

Metadata

Assignees

Labels

CherryPickApprovedUsed during the release process for point releasesFrozenDueToAgecompiler/runtimeIssues related to the Go compiler and/or runtime.genericsIssue is related to generics

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions