From 99dbabcb8225c53e302da9191388650b6b237754 Mon Sep 17 00:00:00 2001 From: Erik Rauer Date: Tue, 29 Dec 2020 16:21:15 -0600 Subject: [PATCH] Fix error in `vector/_nth` Similar to `vector/_first` and `vector/_last`, `vector/_nth` would not check for the case of an empty vector and would divide by 0. This changes the instruction so that it simply throws `:ignore-instruction` in that case. --- src/propeller/push/instructions/vector.cljc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/propeller/push/instructions/vector.cljc b/src/propeller/push/instructions/vector.cljc index d8f695d..fd8f66f 100755 --- a/src/propeller/push/instructions/vector.cljc +++ b/src/propeller/push/instructions/vector.cljc @@ -121,7 +121,9 @@ (fn [stack state] (let [lit-stack (get-vector-literal-type stack)] (make-instruction state - #(get %2 (mod %1 (count %2))) + #(if (empty? %2) + :ignore-instruction + (get %2 (mod %1 (count %2)))) [:integer stack] lit-stack))))