🐛 Fix safe-subvec 3-arity evaluating (count v) before nil check

The 3-arity of safe-subvec called (count v) in a let binding before
checking (some? v). While (count nil) returns 0 in Clojure and does
not crash, the nil guard was dead code. Restructure to check (some? v)
first with an outer when, then compute size inside the guarded block.
This commit is contained in:
Andrey Antukh 2026-04-14 20:11:46 +00:00 committed by Belén Albeza
parent 1cc860807e
commit d73ab3ec92

View File

@ -1149,11 +1149,11 @@
(> start 0) (< start (count v))) (> start 0) (< start (count v)))
(subvec v start))) (subvec v start)))
([v start end] ([v start end]
(let [size (count v)] (when (some? v)
(when (and (some? v) (let [size (count v)]
(>= start 0) (< start size) (when (and (>= start 0) (< start size)
(>= end 0) (<= start end) (<= end size)) (>= end 0) (<= start end) (<= end size))
(subvec v start end))))) (subvec v start end))))))
(defn append-class (defn append-class
[class current-class] [class current-class]