the sum operation now supports dicts too

This commit is contained in:
2024-05-14 04:56:24 +02:00
parent 4151f3f5e2
commit efc92d434b
2 changed files with 9 additions and 0 deletions
+8
View File
@@ -61,6 +61,14 @@ func evalPlus(ctx ExprContext, self *term) (v any, err error) {
} else {
v, err = sumAnyFract(leftValue, rightValue)
}
} else if IsDict(leftValue) && IsDict(rightValue) {
leftDict, _ := leftValue.(map[any]any)
rightDict, _ := rightValue.(map[any]any)
c := CloneMap(leftDict)
for key, value := range rightDict {
c[key] = value
}
v = c
} else {
err = self.errIncompatibleTypes(leftValue, rightValue)
}