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

reflect: Type interface is unimplemented comparable (generics) #51179

Closed
Code-Hex opened this issue Feb 14, 2022 · 7 comments
Closed

reflect: Type interface is unimplemented comparable (generics) #51179

Code-Hex opened this issue Feb 14, 2022 · 7 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge generics Issue is related to generics NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@Code-Hex
Copy link

Code-Hex commented Feb 14, 2022

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

$ gotip version
go version devel go1.18-e50f0f372b Fri Feb 11 05:11:58 2022 +0000 darwin/arm64

What did you do?

The document for reflect.Type interface has described is comparable.

Type values are comparable, such as with the == operator, so they can be used as map keys.

However, I tried to compare with a function using generics comparable, and I get a compilation error.

What did you expect to see?

compilable

What did you see instead?

compilation error.

https://go.dev/play/p/vPcBpD86rST?v=gotip

@hopehook
Copy link
Member

hopehook commented Feb 14, 2022

I find it is work fine at the my local go source code, which is failed on the go playground.

  • my local version success: go version devel go1.18-a991d9dc27 Thu Jan 27 05:30:27 2022 +0000 darwin/amd64
  • playground version failed: devel go1.18-5bd734839d Sun Feb 13 02:11:11 2022 +0000

So i compiled a new one, it failed also.

  • latest source code of master branch failed: go version devel go1.18-badbc52d82 Mon Feb 14 05:18:03 2022 +0000 darwin/amd64

@hopehook
Copy link
Member

@griesemer

@dmitshur
Copy link
Contributor

dmitshur commented Feb 14, 2022

Also CC @findleyr.

Placing it in 1.18 milestone to at least investigate whether something about this needs to be done for 1.18.

@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 14, 2022
@dmitshur dmitshur added this to the Go1.18 milestone Feb 14, 2022
@ianlancetaylor
Copy link
Contributor

It's true that reflect.Type is not treated as a comparable type, and it's true that that may be problematic in some cases. That said, we aren't going to do anything here for 1.18.

@ianlancetaylor
Copy link
Contributor

See discussion at #51338 for a way to fix this.

@ianlancetaylor ianlancetaylor modified the milestones: Go1.19, Go1.20 Jun 24, 2022
@ianlancetaylor
Copy link
Contributor

Rolling forward to 1.20.

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 7, 2022
@ianlancetaylor
Copy link
Contributor

Closing in favor of #56548 which attempts to address the general issue.

@ianlancetaylor ianlancetaylor closed this as not planned Won't fix, can't repro, duplicate, stale Nov 4, 2022
@ianlancetaylor ianlancetaylor added the generics Issue is related to generics label Nov 4, 2022
@golang golang locked and limited conversation to collaborators Nov 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge generics Issue is related to generics NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
Development

No branches or pull requests

5 participants