Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/api: TestCheck panics on exported types that are type aliases #64958

Closed
dhobsd opened this issue Jan 4, 2024 · 1 comment
Closed

cmd/api: TestCheck panics on exported types that are type aliases #64958

dhobsd opened this issue Jan 4, 2024 · 1 comment
Labels
FixPending Issues that have a fix which has not yet been reviewed or submitted. NeedsFix The path to resolution is known, but the work has not been done. Testing An issue that has been verified to require only test changes, not just a test failure.
Milestone

Comments

@dhobsd
Copy link
Contributor

dhobsd commented Jan 4, 2024

Go version

go version devel go1.22-6db1102605 Wed Jan 3 21:01:56 2024 +0000 linux/amd64

What operating system and processor architecture are you using (go env)?

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/usr/local/google/home/dhobsd/.cache/go-build'
GOENV='/usr/local/google/home/dhobsd/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/usr/local/google/home/dhobsd/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/usr/local/google/home/dhobsd/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/google/home/dhobsd/gocontrib/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/google/home/dhobsd/gocontrib/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='devel go1.22-6db1102605 Wed Jan 3 21:01:56 2024 +0000'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/usr/local/google/home/dhobsd/gocontrib/go/src/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 -ffile-prefix-map=/tmp/go-build1790854647=/tmp/go-build -gno-record-gcc-switches'

What did you do?

This was actually encountered in the Fuchsia port, but it applies here. If one introduces an exported type in the Go API that aliases a basic type, TestCheck will fail. I have a patch and test to fix this that I'll be uploading shortly once I have an issue number.

What did you expect to see?

I expected TestCheck to pass.

What did you see instead?

interface conversion: types.Type is *types.Basic, not *types.Named

@gopherbot
Copy link

Change https://go.dev/cl/554076 mentions this issue: cmd/api: fix panic on exported basic type aliases

@bcmills bcmills added Testing An issue that has been verified to require only test changes, not just a test failure. NeedsFix The path to resolution is known, but the work has not been done. FixPending Issues that have a fix which has not yet been reviewed or submitted. labels Jan 4, 2024
@bcmills bcmills added this to the Backlog milestone Jan 4, 2024
@dmitshur dmitshur modified the milestones: Backlog, Go1.22 Jan 8, 2024
ezz-no pushed a commit to ezz-no/go-ezzno that referenced this issue Feb 18, 2024
The order of emitting named type and type aliases in the `Walker`'s
`emitType` function is inverted. When the type alias references a basic
type, this causes a panic as the type assertion on `*types.Named` fails.
This change reorders the logic such that type aliases are emitted prior
to this type assertion.

Fixes golang#64958

Change-Id: I52dbe13999978912ded788d9cf4948103869bcfa
Reviewed-on: https://go-review.googlesource.com/c/go/+/554076
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FixPending Issues that have a fix which has not yet been reviewed or submitted. NeedsFix The path to resolution is known, but the work has not been done. Testing An issue that has been verified to require only test changes, not just a test failure.
Projects
None yet
Development

No branches or pull requests

4 participants