Permalink
Browse files

warn on referred vars that don't exist. parse-ns should not emit warn…

…ings
  • Loading branch information...
1 parent 7153b29 commit 782e10ed2be766323d2bc7560dda636e30eaa647 @swannodette swannodette committed Sep 29, 2013
Showing with 10 additions and 1 deletion.
  1. +9 −0 src/clj/cljs/analyzer.clj
  2. +1 −1 src/clj/cljs/compiler.clj
@@ -656,6 +656,13 @@
(when (io/resource relpath)
(analyze-file relpath))))))
+(defn check-uses [uses env]
+ (doseq [[sym lib] uses]
+ (when (and (:undeclared *cljs-warnings*)
+ (= (get-in @namespaces [lib :defs sym] ::not-found) ::not-found))
+ (warning env
+ (str "WARNING: Referred var " lib "/" sym " does not exist")))))
+
(defmethod parse 'ns
[_ env [_ name & args :as form] _]
(assert (symbol? name) "Namespaces must be named by a symbol.")
@@ -744,6 +751,8 @@
{} (remove (fn [[r]] (= r :refer-clojure)) args))]
(when (seq @deps)
(analyze-deps @deps))
+ (when (seq uses)
+ (check-uses uses env))
(set! *cljs-ns* name)
(load-core)
(doseq [nsym (concat (vals requires-macros) (vals uses-macros))]
@@ -870,7 +870,7 @@
(loop [forms (ana/forms-seq src)]
(if (seq forms)
(let [env (ana/empty-env)
- ast (ana/analyze env (first forms))]
+ ast (ana/no-warn (ana/analyze env (first forms)))]
(if (= (:op ast) :ns)
(let [ns-name (:name ast)
deps (merge (:uses ast) (:requires ast))]

0 comments on commit 782e10e

Please sign in to comment.