Skip to content

Commit 6b19f94

Browse files
author
Stuart Sierra
committed
TNS-38: ignore dependency on self, for CLJS
In Clojure (.clj) code, a namespace depending on itself makes no sense. But it is perfectly reasonable for a ClojureScript (.cljs) file to depend on a Clojure (.clj) file for macro definitions in the same namespace, via :require-macros. More generally, this means that a "namespace" is logically defined in multiple files, which tools.namespace does not yet handle. This causes spurious circular-dependency error in tools. See, for example, clojure-emacs/refactor-nrepl#127 It is easy to work around the specific case of self-dependency via :require-macros, which has no meaning anywhere else. As a consequence, tools.namespace will no longer throw an exception if an ordinary Clojure namespace tries to :require itself.
1 parent f9f11f4 commit 6b19f94

File tree

1 file changed

+5
-2
lines changed
  • src/main/clojure/clojure/tools/namespace

1 file changed

+5
-2
lines changed

src/main/clojure/clojure/tools/namespace/parse.cljc

+5-2
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@
123123
(defn deps-from-ns-decl
124124
"Given an (ns...) declaration form (unevaluated), returns a set of
125125
symbols naming the dependencies of that namespace. Handles :use and
126-
:require clauses but not :load."
126+
:require clauses but not :load. Ignores a namespace depending on
127+
itself, for example a .cljs file with :require-macros on the .clj
128+
file of the same namespace."
127129
[decl]
128-
(set (mapcat deps-from-ns-form decl)))
130+
(disj (set (mapcat deps-from-ns-form decl))
131+
(name-from-ns-decl decl)))

0 commit comments

Comments
 (0)