Fix bugs in vector/_subvec
There were two independent bugs in `vector/_subvec` that were turned up by our `test.check` testing. The first was that the order of the arguments was wrong and `stop-raw` and `start-raw` were flipped. The second was that `stop` wasn't max'ed with 0, which meant it could sometimes be negative, leading to an `IndexOutOfBoundsException`.
This commit is contained in:
parent
d1e863a23a
commit
fc26886815
@ -208,9 +208,9 @@
|
||||
^{:stacks #{:integer}}
|
||||
(fn [stack state]
|
||||
(make-instruction state
|
||||
(fn [stop-raw start-raw vect]
|
||||
(fn [start-raw stop-raw vect]
|
||||
(let [start (min (count vect) (max 0 start-raw))
|
||||
stop (min (count vect) (max start-raw stop-raw))]
|
||||
stop (min (count vect) (max 0 start-raw stop-raw))]
|
||||
(subvec vect start stop)))
|
||||
[:integer :integer stack]
|
||||
stack)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user