From d5f115f81c74ab0f522c5623fe7316467f077e0b Mon Sep 17 00:00:00 2001 From: Erik Rauer Date: Sun, 3 Jan 2021 18:31:12 -0600 Subject: [PATCH] Fix `vector/_replacefirst` This changes the function to throw `:ignore-instruction` if the replacement value is not present in the vector. --- src/propeller/push/instructions/vector.cljc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/propeller/push/instructions/vector.cljc b/src/propeller/push/instructions/vector.cljc index fd8f66f..b2df4da 100755 --- a/src/propeller/push/instructions/vector.cljc +++ b/src/propeller/push/instructions/vector.cljc @@ -183,7 +183,10 @@ (let [lit-stack (get-vector-literal-type stack)] (make-instruction state (fn [lit1 lit2 vect] - (assoc vect (utils/indexof lit1 vect) lit2)) + (let [replaceindex (utils/indexof lit1 vect)] + (if (= replaceindex -1) + :ignore-instruction + (assoc vect replaceindex lit2)))) [lit-stack lit-stack stack] stack))))