From 0031acbcbce94ff1c3c2144b6bdb1b7ccfadb9ad Mon Sep 17 00:00:00 2001 From: James Shubin Date: Mon, 11 Aug 2025 17:49:56 -0400 Subject: [PATCH] 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. --- lang/funcs/structs/composite.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lang/funcs/structs/composite.go b/lang/funcs/structs/composite.go index cde6d2ce..47a77483 100644 --- a/lang/funcs/structs/composite.go +++ b/lang/funcs/structs/composite.go @@ -292,13 +292,16 @@ func (obj *CompositeFunc) Call(ctx context.Context, args []types.Value) (types.V } case types.KindMap: + count := 0 for i, arg := range args { if i%2 == 0 { - key1 := fmt.Sprintf("key:%d", i) + key1 := fmt.Sprintf("key:%d", count) st.V[key1] = arg } else { - key2 := fmt.Sprintf("val:%d", i) + key2 := fmt.Sprintf("val:%d", count) st.V[key2] = arg + + count++ // increment for next even number } }