-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
DocumentationIssues describing a change to documentation.Issues describing a change to documentation.FrozenDueToAge
Description
- The declaration of
comparable
inbuiltin
should reflect the decision that its underlying type is not itself (see spec: document definition ofcomparable
#50791):
-type comparable comparable
+type comparable interface{ comparable }
- The doc comment lists interfaces as comparable:
implemented by all comparable types (booleans, numbers, strings, pointers, channels, interfaces, arrays of comparable types, structs whose fields are all comparable types).
However, according to the spec not all interfaces implement comparable
:
a type T implements comparable if:
- T is not an interface type and T supports the operations == and !=; or
- T is an interface type and each type in T's type set implements comparable.
Even though interfaces that are not type parameters can be compared (possibly causing a run-time panic) they do not implement comparable.
Maybe the doc comment should be more precise.
What version of Go are you using (go version
)?
$ go version go version devel go1.18-9e0de1fe7b Tue Feb 8 19:03:52 2022 +0000 darwin/arm64
Metadata
Metadata
Assignees
Labels
DocumentationIssues describing a change to documentation.Issues describing a change to documentation.FrozenDueToAge