The following changes should fix real and potential problems regarding how variables are set from function return values. In assign from call expressions, Values in caller frame are now directly assigned from function calls (call(), binCall() or builtins). The assignement is performed with reflect Set methods or variants, instead of "=" operator, to enforce runtime type checks. The assignX() and assignX2() builtins are now removed in favor of above method. The representation of nil for pointer on struct has been fixed. The identification of channel is fixed in for-range channel expression.
16 lines
144 B
Go
16 lines
144 B
Go
package main
|
|
|
|
import "fmt"
|
|
|
|
type Foo struct{}
|
|
|
|
func foo() *Foo { return nil }
|
|
|
|
func main() {
|
|
f := foo()
|
|
fmt.Println(f)
|
|
}
|
|
|
|
// Output:
|
|
// <nil>
|