fix: index expression on binary map (#223)

This commit is contained in:
Marc Vertes
2019-06-13 17:35:52 +02:00
committed by Ludovic Fernandez
parent 146cac6a0f
commit cd12274ec6
2 changed files with 21 additions and 1 deletions

20
_test/map17.go Normal file
View File

@@ -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

View File

@@ -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