Skip to content

Commit 8b70d75

Browse files
committed
CLJS-1368: cljs.analyzer tests broken, undeclared-var warning doesn't work
loaded-ns? incorrectly considered ClojureScript namespaces. Only consider JavaScript libraries that cannot curretnly be analyzed.
1 parent f2fd1c0 commit 8b70d75

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

src/main/clojure/cljs/analyzer.cljc

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -549,11 +549,12 @@
549549
(fn [env prefix suffix]
550550
(warning :undeclared-var env {:prefix prefix :suffix suffix})))
551551

552-
(defn loaded-ns?
552+
(defn loaded-js-ns?
553+
"Check if a JavaScript namespace has been loaded. JavaScript vars are
554+
not currently checked."
553555
#?(:cljs {:tag boolean})
554556
[env prefix]
555-
(if-not (nil? (gets @env/*compiler* ::namespaces prefix))
556-
true
557+
(when-not (gets @env/*compiler* ::namespaces prefix)
557558
(let [ns (:ns env)]
558559
(if-not (nil? (get (:requires ns) prefix))
559560
true
@@ -566,19 +567,19 @@
566567
(let [warn (confirm-var-exist-warning env prefix suffix)]
567568
(confirm-var-exists env prefix suffix warn)))
568569
([env prefix suffix missing-fn]
569-
(let [sufstr (str suffix)
570-
suffix-str (if (and #?(:clj (not= ".." sufstr)
571-
:cljs (not (identical? ".." sufstr))) ;; leave cljs.core$macros/.. alone
572-
#?(:clj (re-find #"\." sufstr)
573-
:cljs ^boolean (.test #"\." sufstr)))
574-
(first (string/split sufstr #"\."))
575-
suffix)
576-
suffix (symbol suffix-str)]
577-
(when (and (not (implicit-import? env prefix suffix))
578-
(not (loaded-ns? env prefix))
579-
(not (and (= 'cljs.core prefix) (= 'unquote suffix)))
580-
(nil? (gets @env/*compiler* ::namespaces prefix :defs suffix)))
581-
(missing-fn env prefix suffix)))))
570+
(let [sufstr (str suffix)
571+
suffix-str (if (and #?(:clj (not= ".." sufstr)
572+
:cljs (not (identical? ".." sufstr))) ;; leave cljs.core$macros/.. alone
573+
#?(:clj (re-find #"\." sufstr)
574+
:cljs ^boolean (.test #"\." sufstr)))
575+
(first (string/split sufstr #"\."))
576+
suffix)
577+
suffix (symbol suffix-str)]
578+
(when (and (not (implicit-import? env prefix suffix))
579+
(not (loaded-js-ns? env prefix))
580+
(not (and (= 'cljs.core prefix) (= 'unquote suffix)))
581+
(nil? (gets @env/*compiler* ::namespaces prefix :defs suffix)))
582+
(missing-fn env prefix suffix)))))
582583

583584
(defn confirm-var-exists-throw []
584585
(fn [env prefix suffix]

0 commit comments

Comments
 (0)