lang: funcs: structs: Map indexes use half the integers
We want the pattern to be key:0, val:0, key:1, val:1, and so on... This was previously using 0,1,2,3... When we use Call directly, we need to fix this. Previously this was dead code which is why the bug wasn't caught.
This commit is contained in:
@@ -292,13 +292,16 @@ func (obj *CompositeFunc) Call(ctx context.Context, args []types.Value) (types.V
|
|||||||
}
|
}
|
||||||
|
|
||||||
case types.KindMap:
|
case types.KindMap:
|
||||||
|
count := 0
|
||||||
for i, arg := range args {
|
for i, arg := range args {
|
||||||
if i%2 == 0 {
|
if i%2 == 0 {
|
||||||
key1 := fmt.Sprintf("key:%d", i)
|
key1 := fmt.Sprintf("key:%d", count)
|
||||||
st.V[key1] = arg
|
st.V[key1] = arg
|
||||||
} else {
|
} else {
|
||||||
key2 := fmt.Sprintf("val:%d", i)
|
key2 := fmt.Sprintf("val:%d", count)
|
||||||
st.V[key2] = arg
|
st.V[key2] = arg
|
||||||
|
|
||||||
|
count++ // increment for next even number
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user