Welcome! Please see the About page for a little more info on how this works.

+1 vote
in core.rrb-vector by
retagged by

expected:

(reduce-kv vector nil [])
=> nil
(reduce-kv vector nil [1])
=> [nil 0 1]

actual in CLJS:

(reduce-kv vector nil (clojure.core.rrb-vector/vec []))
Error: No item 0 in vector of length 0
    at Object.cljs$core$vector_index_out_of_bounds [as vector_index_out_of_bounds] (http://localhost:8080/cljs-runtime/cljs.core.js:19788:8)
    at Object.clojure$core$rrb_vector$rrbt$IVecImpl$_array_for$arity$2 (http://localhost:8080/cljs-runtime/clojure.core.rrb_vector.rrbt.js:1028:18)
    at Object.cljs$core$IKVReduce$_kv_reduce$arity$3 (http://localhost:8080/cljs-runtime/clojure.core.rrb_vector.rrbt.js:613:21)
    at Object.cljs$core$_kv_reduce [as _kv_reduce] (http://localhost:8080/cljs-runtime/cljs.core.js:2359:13)
(reduce-kv vector nil (clojure.core.rrb-vector/vec [1]))
=> [nil 0 1]

actual in CLJ:

(reduce-kv vector nil (clojure.core.rrb-vector/vec [])) 
Execution error (IndexOutOfBoundsException) at clojure.core.rrb_vector.rrbt.Vector/arrayFor (rrbt.clj:806).
(reduce-kv vector nil (clojure.core.rrb-vector/vec [1])) 
=> [nil 0 1]

*"vector nil" part is not important here, it is just to justify calling reduce-kv.

Friday night, forgot to add any versions info:

 :deps  {org.clojure/clojure              {:mvn/version "1.10.1"}
         org.clojure/clojurescript        {:mvn/version "1.10.597"}
         org.clojure/core.rrb-vector      {:mvn/version "0.1.1"}

3 Answers

+1 vote
by
selected by
 
Best answer

Thanks for the report. I can reproduce this in the latest version of the core.rrb-vector code.
From a quick look, this is probably straightforward to fix -- the code implementing reduce-kv for core.rrb-vector vectors tries to access element 0 of a vector when you call it with an empty vector. It should not try to do that. It is probably a straightforward 1-line fix in the kv-reduce implementation.

0 votes
by
0 votes
by

core.rrb-vector version 0.1.2 has been released. The only change from version 0.1.1 is a fix for this issue, both in the CLJ and CLJS versions of the core.rrb-vector code.

...