cmd/compile: enable new comparable
behavior by default [freeze exception]
#57011
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
FrozenDueToAge
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
release-blocker
Milestone
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 satisfycomparable
. 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
The text was updated successfully, but these errors were encountered: