Welcome! Please see the About page for a little more info on how this works.

+1 vote
in ClojureScript by
cljs.user=> (def a #js {})
#'cljs.user/a
cljs.user=> (set! a -x false)
WARNING: Use of undeclared Var cljs.user/-x at line 1 <cljs repl>
nil
cljs.user=> a
nil

The root cause is that the code below taken from cljs.analyzer does not distinguish between a false/nil alt and a completely missing value.

(defmethod parse 'set!
  [_ env [_ target val alt :as form] _ _]
  (let [[target val] (if alt
                       ;; (set! o -prop val)
                       [`(. ~target ~val) alt]
                       [target val])]
    ...))

One way to fix it would be to check the value of (count form) explicitly.

Please log in or register to answer this question.

...