fix: handle nil interface conversion
This commit is contained in:
12
_test/interface43.go
Normal file
12
_test/interface43.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
v := interface{}(nil)
|
||||
|
||||
fmt.Println(v)
|
||||
}
|
||||
|
||||
// Output:
|
||||
// <nil>
|
||||
@@ -225,6 +225,9 @@ func convert(n *node) {
|
||||
next := getExec(n.tnext)
|
||||
|
||||
if c.isNil() { // convert nil to type
|
||||
if n.child[0].typ.cat == interfaceT {
|
||||
typ = reflect.TypeOf((*valueInterface)(nil)).Elem()
|
||||
}
|
||||
n.exec = func(f *frame) bltn {
|
||||
dest(f).Set(reflect.New(typ).Elem())
|
||||
return next
|
||||
|
||||
Reference in New Issue
Block a user