Permalink
Browse files

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:
#1

Also added to tools.namespace:
clojure/tools.namespace@41cd3c3
  • Loading branch information...
1 parent 5c03463 commit 09c519b18ec631c9a01be905a320062401485450 @stuartsierra committed Jun 3, 2013
Showing with 3 additions and 5 deletions.
  1. +3 −5 src/com/stuartsierra/dependency.clj
View
8 src/com/stuartsierra/dependency.clj
@@ -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)))

0 comments on commit 09c519b

Please sign in to comment.