Skip to content

Commit d5e8da2

Browse files
author
dnolen
committed
assert that argument to exists? is a symbol, clarify docstring
1 parent 80c77a2 commit d5e8da2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/clojure/cljs/core.cljc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -960,11 +960,12 @@
960960
(core/defmacro string? [x]
961961
(bool-expr (core/list 'js* "typeof ~{} === 'string'" x)))
962962

963-
;; TODO: x must be a symbol, not an arbitrary expression
964963
(core/defmacro exists?
965964
"Return true if argument exists, analogous to usage of typeof operator
966-
in JavaScript."
965+
in JavaScript to check for undefined top-level var. x must be a symbol but
966+
need not be top-level."
967967
[x]
968+
(core/assert (core/symbol? x))
968969
(let [x (cond-> (:name (cljs.analyzer/resolve-var &env x))
969970
(= "js" (namespace x)) name)
970971
segs (string/split (core/str (string/replace x #"\/" ".")) #"\.")

0 commit comments

Comments
 (0)