Skip to content

Commit 41cd3c3

Browse files
author
Stuart Sierra
committed
A node may not depend on itself
Also simplify generation of exception message. The *print-length* binding was paranoid: nodes should probably not be large data structures. Originally reported by "tgoossens" here: stuartsierra/dependency#1
1 parent 708cbf7 commit 41cd3c3

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/main/clojure/clojure/tools/namespace/dependency.clj

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,9 @@
7070
(set (keys dependents))))
7171
DependencyGraphUpdate
7272
(depend [graph node dep]
73-
(when (depends? graph dep node)
74-
(let [^String msg (binding [*print-length* 10]
75-
(str "Circular dependency between "
76-
(pr-str node) " and " (pr-str dep)))]
77-
(throw (Exception. msg))))
73+
(when (or (= node dep) (depends? graph dep node))
74+
(throw (Exception. (str "Circular dependency between "
75+
(pr-str node) " and " (pr-str dep)))))
7876
(MapDependencyGraph.
7977
(update-in dependencies [node] set-conj dep)
8078
(update-in dependents [dep] set-conj node)))

0 commit comments

Comments
 (0)