Skip to content

Commit 62ac5ad

Browse files
authored
Makeclasspath-namespaces resilient to faulty ns declarations (#159)
Fixes #158
1 parent c0e24f7 commit 62ac5ad

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Changelog
22

33
## master (unreleased)
4+
* [#158](https://github.com/clojure-emacs/orchard/issues/158): Make classpath-namespaces resilient to faulty ns declarations.
45

56
## 0.9.2 (2022-02-22)
67

src/orchard/namespace.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
(cond
3232
(#{::eof ::fail} found) nil
3333
(and (list? found)
34-
(-> found first #{`ns 'ns}))
34+
(-> found first #{`ns 'ns})
35+
(symbol? (second found)))
3536
(second found)
3637
:else (recur))))))
3738

test/orchard/namespace_test.clj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
(testing "when multiple ns forms are present"
6363
(spit url "(ns ns1) (ns ns2) (ns ns3)")
6464
(is (= 'ns1 (sut/read-namespace uri))))
65+
(testing "when ns form is invalid"
66+
(spit url "(ns (:require [clojure.string]))")
67+
(is (nil? (sut/read-namespace uri))))
6568
(testing "of top-level forms only"
6669
(spit url "(comment (ns ns1)) (ns ns2) (ns ns3)")
6770
(is (= 'ns2 (sut/read-namespace uri))))

0 commit comments

Comments
 (0)