go: reflect: ConvertibleTo returns false in go1.17 for slice values that previously returned true

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

$ go version
go version go1.17 darwin/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="/Users/liggitt/Library/Caches/go-build"
GOENV="/Users/liggitt/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/liggitt/.gvm/pkgsets/go1.17/global/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/liggitt/.gvm/pkgsets/go1.17/global"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/liggitt/.gvm/gos/go1.17"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/liggitt/.gvm/gos/go1.17/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.17"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/liggitt/tmp/convertible117/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/7f/9xt_73f12xlby0w362rgk0s400kjgb/T/go-build2916420994=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Used the reflect ConvertibleTo function (via a call to https://github.com/stretchr/testify/blob/v1.7.0/assert/assertions.go#L78-L96) to compare slices of two different types with identical names/members/layouts in different packages.

This worked as expected prior to go 1.17.

Minimal reproducer at https://github.com/liggitt/convertible117/blob/master/convertible_test.go

What did you expect to see?

gvm use go1.16 && go test ./ -v -count=1
Now using version go1.16
=== RUN   TestConvertible
--- PASS: TestConvertible (0.00s)
PASS
ok  	github.com/liggitt/convertible117	0.629s

What did you see instead?

gvm use go1.17 && go test ./ -v -count=1
Now using version go1.17
=== RUN   TestConvertible
    convertible_test.go:24: !convertible
--- FAIL: TestConvertible (0.00s)
FAIL
FAIL	github.com/liggitt/convertible117	0.566s
FAIL

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Change https://golang.org/cl/343669 can be abandoned, as we don’t generally keep the release-branch’s HTML up to date. The x/website change will correctly update the documentation.