-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Closed
Labels
FrozenDueToAgeLanguageChangeSuggested changes to the Go languageSuggested changes to the Go languageProposal
Milestone
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)
earthboundkid, apparentlymart and ainar-gpascaldekloe
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeLanguageChangeSuggested changes to the Go languageSuggested changes to the Go languageProposal