From b0c490d2f08b45dc79c49cd5da7b2606d9b331fb Mon Sep 17 00:00:00 2001 From: piotr-yuxuan Date: Thu, 27 Oct 2022 13:10:45 +0200 Subject: [PATCH] fix: Key must be integer when assoc called with :kw on a vec --- src/malli/error.cljc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/malli/error.cljc b/src/malli/error.cljc index 2c3740885..90eb31ed2 100644 --- a/src/malli/error.cljc +++ b/src/malli/error.cljc @@ -146,8 +146,11 @@ (defn -fill [x i fill] (-concat x (repeat (- i (count x)) fill))) (defn -push [x k v fill] - (let [x' (cond-> x (and (int? k) (sequential? x) (> k (count x))) (-fill k fill))] - (cond (or (nil? x') (associative? x')) (assoc x' k v) + (let [i (when (int? k) k) + x' (cond-> x (and i (sequential? x) (> k (count x))) (-fill k fill))] + (cond (nil? x') (assoc x' k v) + (and (associative? x') i) (assoc x' i v) + (associative? x') (assoc x' (count x') v) (set? x') (conj x' v) :else (apply list (assoc (vec x') k v)))))