Fork me on GitHub
#cljs-dev
<
2019-11-16
>
lilactown00:11:11

is there a JIRA issue for the when bug? I keep running into it

mfikes00:11:49

What’s the when bug?

lilactown00:11:33

I have this code:

(defn sig []
  (when (exists? (.-$$Signature$$ js/window))
      (.$$Signature$$ js/window)))
and elsewhere it's usage outputs:
(.cljs$core$IFn$_invoke$arity$0 ? .cljs$core$IFn$_invoke$arity$0() : .call(null));

mhuebert00:11:11

@lilactown https://clojure.atlassian.net/browse/CLJS-2950 is a nice example of using type inference to speed sth up

lilactown04:11:48

(let [forms  '[^:meta {:a 1}
               {:b 2}]
      env (ana/empty-env)]
  (for [f forms]
    (cljs.analyzer/infer-tag env (ana/analyze env f))))
;; => (nil cljs.core/IMap)
it seems that adding metadata to a form loses it's type

lilactown04:11:02

hmm. i wonder if it's because my REPL test here is using an empty env

lilactown04:11:30

same with a live compiler env

mhuebert09:11:02

something doesn’t look quite right there

mhuebert09:11:32

or maybe I’m not sure what you are doing

mhuebert09:11:34

i see. i can replicate this. looks like the use of ^:meta is blowing away the tag.

mhuebert09:11:40

[(j/infer-tag {})
 (j/infer-tag ^:meta {})
 (j/infer-tag ^hello {})
 (j/infer-tag (doto {} (alter-meta! assoc :a 1)))]
=> [cljs.core/IMap nil hello cljs.core/IMap]