From cd12274ec608de2d8fad98aec2eb19d1ab5c4948 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Thu, 13 Jun 2019 17:35:52 +0200 Subject: [PATCH] fix: index expression on binary map (#223) --- _test/map17.go | 20 ++++++++++++++++++++ interp/run.go | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 _test/map17.go diff --git a/_test/map17.go b/_test/map17.go new file mode 100644 index 00000000..14e7a618 --- /dev/null +++ b/_test/map17.go @@ -0,0 +1,20 @@ +package main + +import "net/http" + +type T struct { + header string +} + +func (b *T) ServeHTTP(rw http.ResponseWriter, req *http.Request) { + if b.header != "" { + req.Header[b.header] = []string{"hello"} + } +} + +func main() { + println("ok") +} + +// Output: +// ok diff --git a/interp/run.go b/interp/run.go index dce48e6e..9771a688 100644 --- a/interp/run.go +++ b/interp/run.go @@ -917,7 +917,7 @@ func getIndexArray(n *Node) { func getIndexMap(n *Node) { value0 := genValue(n.child[0]) // map tnext := getExec(n.tnext) - z := reflect.New(n.child[0].typ.val.TypeOf()).Elem() + z := reflect.New(n.child[0].typ.TypeOf().Elem()).Elem() if n.child[1].rval.IsValid() { // constant map index mi := n.child[1].rval