Skip to content

cmd/compile: enable new comparable behavior by default [freeze exception] #57011

Closed

Description

@griesemer

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

Activity

  1. added
    NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.
    on Nov 30, 2022
  2. 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
  3. ianlancetaylor commented on Nov 30, 2022

    @ianlancetaylor
    Contributor

    CC @golang/release

  4. added this to the Go1.20 milestone on Nov 30, 2022
  5. heschi commented on Dec 1, 2022

    @heschi
    Contributor

    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.

  6. gopherbot commented on Dec 1, 2022

    @gopherbot
    Contributor

    Change https://go.dev/cl/454575 mentions this issue: go/types, types2: make the new comparable semantics the default

  7. griesemer commented on Dec 1, 2022

    @griesemer
    ContributorAuthor

    This change has been submitted. Closing.

  8. locked and limited conversation to collaborators on Dec 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.compiler/runtimeIssues related to the Go compiler and/or runtime.release-blocker

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions