fix: correct type assertion for bin func types (#588)
This commit is contained in:
16
_test/type21.go
Normal file
16
_test/type21.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
t := time.Date(2009, time.November, 10, 23, 4, 5, 0, time.UTC)
|
||||
v := reflect.ValueOf(t.String)
|
||||
f := v.Interface().(func() string)
|
||||
println(f())
|
||||
}
|
||||
|
||||
// Output:
|
||||
// 2009-11-10 23:04:05 +0000 UTC
|
||||
@@ -1503,7 +1503,12 @@ func (interp *Interpreter) cfg(root *node, pkgID string) ([]*node, error) {
|
||||
}
|
||||
}
|
||||
if n.anc.action != aAssignX {
|
||||
n.typ = n.child[1].typ
|
||||
if n.child[0].typ.cat == valueT {
|
||||
// Avoid special wrapping of interfaces and func types.
|
||||
n.typ = &itype{cat: valueT, rtype: n.child[1].typ.TypeOf()}
|
||||
} else {
|
||||
n.typ = n.child[1].typ
|
||||
}
|
||||
n.findex = sc.add(n.typ)
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user