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/compile: generic function appears to use incorrect type descriptor #52026

Closed
QuantumGhost opened this issue Mar 30, 2022 · 7 comments
Closed
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@QuantumGhost
Copy link

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

$ go version
go version go1.18 darwin/arm64

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="on"
GOARCH="arm64"
GOBIN=""
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOOS="darwin"
GOPROXY="https://goproxy.io,https://mirrors.aliyun.com/goproxy/"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOVCS=""
GOVERSION="go1.18"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
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 -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/yv/fd8s2yw54cldnj29jx3qxrh80000gn/T/go-build4280234465=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Go 2 Playground Link

What did you expect to see?

Type assertion to None returns true.
Type Switch prints s is a None.

What did you see instead?

Type assertion to None returned false.
Type Switch prints oops.

@ianlancetaylor ianlancetaylor changed the title affected/package: core language cmd/compile: generic function appears to use incorrect type descriptor Mar 30, 2022
@ianlancetaylor ianlancetaylor added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker labels Mar 30, 2022
@ianlancetaylor ianlancetaylor added this to the Go1.19 milestone Mar 30, 2022
@ianlancetaylor
Copy link
Contributor

CC @randall77 @mdempsky

@kraleva
Copy link

kraleva commented Mar 30, 2022

Since you are returning a generic type from your returnOption function, go would expect None to be generic as well. If you do change it to None[T], it seems to work for me :) At least that is a possible solution to the problem.

@go101
Copy link

go101 commented Mar 30, 2022

It is really a bug.

It looks the problem is gone if the line s = returnOption[int](0) is changed to s = returnOption[string](0).

@ii64
Copy link

ii64 commented Apr 2, 2022

https://gotipplay.golang.org/p/p-xVGVKSW10

switch (any)(s).(type) {

@gopherbot
Copy link

Change https://go.dev/cl/401034 mentions this issue: cmd/compile: use dictionary to convert type to shaped interface type

@randall77
Copy link
Contributor

@gopherbot please open a backport issue for 1.18.

@gopherbot
Copy link

Backport issue(s) opened: #52691 (for 1.18).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.

@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels May 4, 2022
@golang golang locked and limited conversation to collaborators May 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Projects
None yet
Development

No branches or pull requests

8 participants