Skip to content

Commit b7e3935

Browse files
author
dnolen
committed
make :undeclared-ns warning more helpful, print the path that could
not be found `cljs.closure/source-for-namespace` incorrectly munged nses so that JS keywords like `function` etc. would get rewritten.
1 parent 2f07bc5 commit b7e3935

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/clj/cljs/analyzer.clj

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,10 @@
8989
(str "Use of undeclared Var " (:prefix info) "/" (:suffix info)))
9090

9191
(defmethod error-message :undeclared-ns
92-
[warning-type info]
93-
(str "No such namespace: " (:ns-sym info)))
92+
[warning-type {:keys [ns-sym path] :as info}]
93+
(str "No such namespace: " ns-sym
94+
(when path
95+
(str ", could not locate " path))))
9496

9597
(defmethod error-message :dynamic
9698
[warning-type info]
@@ -369,7 +371,7 @@
369371
;; macros may refer to namespaces never explicitly required
370372
;; confirm that the library at least exists
371373
(nil? (io/resource (util/ns->relpath ns-sym))))
372-
(warning :undeclared-ns env {:ns-sym ns-sym})))
374+
(warning :undeclared-ns env {:ns-sym ns-sym :path (util/ns->relpath ns-sym)})))
373375

374376
(defn core-name?
375377
"Is sym visible from core in the current compilation namespace?"
@@ -1132,7 +1134,7 @@
11321134
(analyze-file src opts)
11331135
(throw
11341136
(error env
1135-
(error-message :undeclared-ns {:ns-sym dep}))))))))))
1137+
(error-message :undeclared-ns {:ns-sym dep :path relpath}))))))))))
11361138

11371139
(defn check-uses [uses env]
11381140
(doseq [[sym lib] uses]

src/clj/cljs/closure.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ should contain the source for the given namespace name."
477477

478478
(defn source-for-namespace
479479
[ns compiler-env]
480-
(let [ns-str (str (comp/munge ns))
480+
(let [ns-str (str (comp/munge ns {}))
481481
path (string/replace ns-str \. \/)
482482
relpath (str path ".cljs")]
483483
(if-let [cljs-res (io/resource relpath)]

0 commit comments

Comments
 (0)