Skip to content

Commit e7f55e8

Browse files
puredangerstuarthalloway
authored andcommitted
CLJ-1176 - source throws error when *read-eval* is :unknown
Signed-off-by: Stuart Halloway <[email protected]>
1 parent 98206ab commit e7f55e8

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/clj/clojure/repl.clj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ itself (not its value) is returned. The reader macro #'x expands to (var x)."}})
150150
(read [] (let [i (proxy-super read)]
151151
(.append text (char i))
152152
i)))]
153-
(read (PushbackReader. pbr))
153+
(if (= :unknown *read-eval*)
154+
(throw (IllegalStateException. "Unable to read source while *read-eval* is :unknown."))
155+
(read (PushbackReader. pbr)))
154156
(str text)))))))
155157

156158
(defmacro source

test/clojure/test_clojure/repl.clj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
(is (= (platform-newlines "(defn foo [])\n") (with-out-str (source clojure.test-clojure.repl.example/foo))))
1616
(is (nil? (source-fn 'non-existent-fn))))
1717

18+
(deftest test-source-read-eval-unknown
19+
(is (thrown? IllegalStateException (binding [*read-eval* :unknown] (source reduce)))))
20+
21+
(deftest test-source-read-eval-false
22+
(is (binding [*read-eval* false] (with-out-str (source reduce)))))
23+
1824
(deftest test-dir
1925
(is (thrown? Exception (dir-fn 'non-existent-ns)))
2026
(is (= '[bar foo] (dir-fn 'clojure.test-clojure.repl.example)))

0 commit comments

Comments
 (0)