fix: correct iterator in map range on binary values (#644)
* fix: correct iterator in map range on binary values The map range iterator was not initialized correctly for values originating from runtime. Fixes #641. * test: deterministic output for map28.go
This commit is contained in:
21
_test/map28.go
Normal file
21
_test/map28.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
)
|
||||
|
||||
func main() {
|
||||
value1 := url.Values{}
|
||||
|
||||
value1.Set("first", "v1")
|
||||
value1.Set("second", "v2")
|
||||
|
||||
l := 0
|
||||
for k, v := range value1 {
|
||||
l += len(k) + len(v)
|
||||
}
|
||||
println(l)
|
||||
}
|
||||
|
||||
// Output:
|
||||
// 13
|
||||
@@ -89,6 +89,8 @@ func (interp *Interpreter) cfg(root *node, pkgID string) ([]*node, error) {
|
||||
switch typ.Kind() {
|
||||
case reflect.Map:
|
||||
n.anc.gen = rangeMap
|
||||
ityp := &itype{cat: valueT, rtype: reflect.TypeOf((*reflect.MapIter)(nil))}
|
||||
sc.add(ityp)
|
||||
ktyp = &itype{cat: valueT, rtype: typ.Key()}
|
||||
vtyp = &itype{cat: valueT, rtype: typ.Elem()}
|
||||
case reflect.String:
|
||||
|
||||
Reference in New Issue
Block a user