Browse files

CLJS-646: single segment namespaces and reify don't work

the exists? call in reify was not correct, it was a property access on
the namespace, which would of course get resolved by the compiler,
creating a symbol foo/foo (in the case where foo is the single segment
namespace). now we actually emit a symbol of the namespace and the type
symbol, the exists? macro now annotates this symbol with
:cljs.analyzer/no-resolve, the analyzer now respects this so the user
won't get spurious warnings from using exists? on vars that don't exist.
  • Loading branch information...
swannodette committed Oct 29, 2013
1 parent d03c15b commit 85ac96e3e2de4a3598c1658f7c1de6cf88734d93
Showing with 8 additions and 3 deletions.
  1. +3 −1 src/clj/cljs/analyzer.clj
  2. +5 −2 src/clj/cljs/core.clj
@@ -247,7 +247,9 @@
:ns full-ns})))))))
(defn resolve-existing-var [env sym]
- (resolve-var env sym confirm-var-exists))
+ (if-not (-> sym meta ::no-resolve)
+ (resolve-var env sym confirm-var-exists)
+ (resolve-var env sym)))
(defn confirm-bindings [env names]
(doseq [name names]
@@ -279,8 +279,11 @@
(defmacro string? [x]
(bool-expr (list 'js* "typeof ~{} === 'string'" x)))
+;; TODO: x must be a symbol, not an arbitrary expression
(defmacro exists? [x]
- (bool-expr (list 'js* "typeof ~{} !== 'undefined'" x)))
+ (bool-expr
+ (list 'js* "typeof ~{} !== 'undefined'"
+ (vary-meta x assoc :cljs.analyzer/no-resolve true))))
(defmacro undefined? [x]
(bool-expr (list 'js* "(void 0 === ~{})" x)))
@@ -576,7 +579,7 @@
ns (-> &env :ns :name)
munge cljs.compiler/munge]
- (when-not (exists? (. ~ns ~(symbol (core/str "-" t))))
+ (when-not (exists? ~(symbol (core/str ns) (core/str t)))
(deftype ~t [~@locals ~meta-sym]
(~'-with-meta [~this-sym ~meta-sym]

0 comments on commit 85ac96e

Please sign in to comment.