Skip to content

Commit

Permalink
A node may not depend on itself
Browse files Browse the repository at this point in the history
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

Also added to tools.namespace:
clojure/tools.namespace@41cd3c3
  • Loading branch information
Stuart Sierra committed Jun 3, 2013
1 parent 5c03463 commit 09c519b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/com/stuartsierra/dependency.clj
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,9 @@
(set (keys dependents))))
DependencyGraphUpdate
(depend [graph node dep]
(when (depends? graph dep node)
(let [^String msg (binding [*print-length* 10]
(str "Circular dependency between "
(pr-str node) " and " (pr-str dep)))]
(throw (Exception. msg))))
(when (or (= node dep) (depends? graph dep node))
(throw (Exception. (str "Circular dependency between "
(pr-str node) " and " (pr-str dep)))))
(MapDependencyGraph.
(update-in dependencies [node] set-conj dep)
(update-in dependents [dep] set-conj node)))
Expand Down

0 comments on commit 09c519b

Please sign in to comment.