Skip to content

Commit

Permalink
read-string should use non-indexing reader
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Feb 5, 2024
1 parent 369d38f commit 1b952c5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/sci/impl/read.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@

(defn read-string
([sci-ctx s]
(let [reader (r/indexing-push-back-reader (r/string-push-back-reader s))]
(let [reader (r/string-push-back-reader s)]
(read sci-ctx reader)))
([sci-ctx opts s]
(let [reader (r/indexing-push-back-reader (r/string-push-back-reader s))]
(let [reader (r/string-push-back-reader s)]
(read sci-ctx opts reader))))

(defn load-string [sci-ctx s]
Expand Down
3 changes: 2 additions & 1 deletion test/sci/core_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,8 @@
(is (thrown-with-msg? #?(:clj Exception :cljs js/Error) #"loop.*allowed"
(tu/eval* "(eval (read-string \"(loop [] (recur))\"))" {:deny '[loop]})))
(is (thrown-with-msg? #?(:clj Exception :cljs js/Error) #"loop.*allowed"
(tu/eval* "(load-string \"(loop [] (recur))\")" {:deny '[loop]}))))
(tu/eval* "(load-string \"(loop [] (recur))\")" {:deny '[loop]})))
(is (nil? (meta (tu/eval* "(read-string \"(+ 1 2 3)\")" nil)))))

(deftest while-test
(is (= 10 (eval* "(def a (atom 0)) (while (< @a 10) (swap! a inc)) @a"))))
Expand Down

0 comments on commit 1b952c5

Please sign in to comment.