From fc26886815c27541f2b856145afdc619ef08d519 Mon Sep 17 00:00:00 2001 From: Nic McPhee Date: Thu, 17 Dec 2020 15:58:11 -0600 Subject: [PATCH] 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`. --- src/propeller/push/instructions/vector.cljc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/propeller/push/instructions/vector.cljc b/src/propeller/push/instructions/vector.cljc index cf88860..eb299b2 100755 --- a/src/propeller/push/instructions/vector.cljc +++ b/src/propeller/push/instructions/vector.cljc @@ -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)))