Comments

From @taradinoc on twitter:
// http://play.golang.org/p/TsxFgLP1l2
package main
import "fmt"
func main() {
i := foo()
fmt.Printf("Hello, %d\n", i)
}
func foo() (x int) {
x = 7
return 5
}
This compiles and runs fine, but if x were a local instead of a return variable, gc
would complain that it was unused. is this an inconsistency that should be fixed?

This comment has been minimized.

The rationale behind excluding return values was that
func foo() (x int) {
return 5
}
assigns to x (implicitly) and doesn't use the result. The spec says
"Implementation restriction: A compiler may make it illegal to declare a variable inside
a function body if the variable is never used."
I don't think x is inside the function body here. Both because of that and because gc
has accepted the program already, I don't think we can change this for Go 1.x.