Closed losinggeneration closed 1 year ago
Change https://go.dev/cl/505795 mentions this issue: doc/go1.21: context.Background and TODO may now appear equal
That equal
function is a really weird way to define equality in Go. 😅
Notably, it does not match the language's definition of equality in https://go.dev/ref/spec#Comparison_operators.
That's absolutely true. I'm glad it was in a public repo to use as an example of how that library's equality could be (mis)used in previous versions of Go.
CC @CAFxX, @neild, @Sajmani.
Note that I sent CL 505795 to update the release notes. I don't think there is anything else to do here.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
This was introduced in 1.21rc1 & 1.21rc2. I bisected release-branch.go1.20 to release-branch.go1.21 and narrowed it down to this commit: 6e5c26084f9f3bc910181854a4ff20851188e222
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
https://go.dev/play/p/eZIlVe7s-Or
What did you expect to see?
Initially I thought it was a breaking change, but as I dug in, it really seems like it only worked as an artifact of undocumented behavior.
What did you see instead?
It's potentially worth pointing out the corrected behavior of this edge case in the release notes. While this works in versions before 1.21, but only worked because
type emptyCtx int
and that both Background & TODO were variables assigned new values of emptyCtx. This wasn't documented and generally not expected behavior.