Skip to content

Commit

Permalink
fix: correct type assertion for bin func types (#588)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvertes committed Apr 20, 2020
1 parent 5e142fd commit 3ed4ec3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
16 changes: 16 additions & 0 deletions _test/type21.go
Original file line number Diff line number Diff line change
@@ -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
7 changes: 6 additions & 1 deletion interp/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 3ed4ec3

Please sign in to comment.