You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cmd/compile: enable new comparable behavior by default [freeze exception] #57011
Proposal #56548 which allows ordinary interfaces to implement comparable has been accepted today. We would like to incorporate this into 1.20 as it will directly influence the kind of generic code people will be able to write.
The respective change was implemented a while ago in go/types, types2, and the compiler, and could be enabled with a compiler flag: -altcomparable (see CL 444635 and CL 444636). By default, the feature was disabled.
I would like to request a freeze exception to enable the feature by default.
CL 454575 makes the new behavior the default and Go 1.20 version dependent, and provides error messages reporting version issues, and adds more tests.
Safety of the change:
If there are any suspected problems with the change, a) by setting the compiler flag -oldcomparable we can confirm if there's an issue related to this change in the first place; and b) if we decide to roll back, all we need to do is to change the flag default (or roll back the CL).
Finally, I note that the new behavior for comparable is in fact the behavior we had implemented until about 6 weeks before the release of Go 1.18, when people perceived an apparent inconsistency (see issue #50646 which was closed on Feb 1, 2022). To err on the side of caution we deliberately restricted what types would satisfy comparable. At this point, and after many proposals and discussions (for a list see #56548), we agreed that the original behavior was in fact what people expect. With the changes here we simply re-establish this original behavior.
cc: golang/release
Reacted by Ian Lance Taylor, Jannis M. Hoffmann, Jo and Rajender Reddy Kompally
changed the title [-]cmd/compile: enable new comparable behavior by default [freeze exception][/-][+]cmd/compile: enable new `comparable` behavior by default [freeze exception][/+]on Nov 30, 2022
Approved after offline discussion. In the future, if it looks like there's going to be trouble with the timeline for a feature like this please let us know and we'll try to see if we can smooth things over.
Activity
[-]cmd/compile: enable new comparable behavior by default [freeze exception][/-][+]cmd/compile: enable new `comparable` behavior by default [freeze exception][/+]ianlancetaylor commentedon Nov 30, 2022
CC @golang/release
heschi commentedon Dec 1, 2022
Approved after offline discussion. In the future, if it looks like there's going to be trouble with the timeline for a feature like this please let us know and we'll try to see if we can smooth things over.
gopherbot commentedon Dec 1, 2022
Change https://go.dev/cl/454575 mentions this issue:
go/types, types2: make the new comparable semantics the defaultgo/types, types2: make the new comparable semantics the default
griesemer commentedon Dec 1, 2022
This change has been submitted. Closing.