Skip to content

Commit

Permalink
CLJS-444: if not given an init form, (def x) compiles to "cljs.user.x…
Browse files Browse the repository at this point in the history
… = undefined;". As a result forms like (def x) and (declare x) now work in the REPL.
  • Loading branch information
David Nolen authored and David Nolen committed Dec 18, 2012
1 parent 9abeb14 commit ab868f2
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/clj/cljs/compiler.clj
Expand Up @@ -351,14 +351,15 @@

(defmethod emit :def
[{:keys [name init env doc export]}]
(when init
(let [mname (munge name)]
(emit-comment doc (:jsdoc init))
(emits mname)
(let [mname (munge name)]
(emit-comment doc (:jsdoc init))
(emits mname)
(if init
(emits " = " init)
(when-not (= :expr (:context env)) (emitln ";"))
(when export
(emitln "goog.exportSymbol('" (munge export) "', " mname ");")))))
(emits " = undefined"))
(when-not (= :expr (:context env)) (emitln ";"))
(when export
(emitln "goog.exportSymbol('" (munge export) "', " mname ");"))))

(defn emit-apply-to
[{:keys [name params env]}]
Expand Down

0 comments on commit ab868f2

Please sign in to comment.