Closed
Description
A coworker sent out a code review with:
func As(err error) (_ Error, ok bool) {
var e Error
return e, errors.As(err, &e)
}
... and during review I said I wasn't sure whether it works. Turns out it worked but it's undefined. It happens to work in cmd/compile and doesn't work in gccgo.
The spec defines assignment order for e.g. a, b = foo(), bar()
or a, b = b, a
but not for return
.
Another example which has different results between gc and gccgo: https://go.dev/play/p/SDMlczFBshC
I propose the spec defines this. My preference would be left to right assignment to results.
But admittedly it might break code like above. (which we fortunately rewrote to be simpler and explicit)
/cc @ianlancetaylor @griesemer (sorry)