Skip to content

Commit

Permalink
fix: Key must be integer when assoc called with :kw on a vec
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-yuxuan committed Oct 27, 2022
1 parent 546eb66 commit b0c490d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/malli/error.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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)))))

Expand Down

0 comments on commit b0c490d

Please sign in to comment.