cljs-dev

ClojureScript compiler & std lib dev, https://clojurescript.org/community/dev
lilactown 2019-11-16T00:12:11.341700Z

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

mfikes 2019-11-16T00:37:49.342Z

What’s the when bug?

lilactown 2019-11-16T00:41:33.343100Z

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));

2019-11-16T00:42:11.343600Z

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

lilactown 2019-11-16T04:10:48.344500Z

(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

lilactown 2019-11-16T04:12:02.344800Z

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

lilactown 2019-11-16T04:24:30.345200Z

same with a live compiler env

2019-11-16T09:22:02.345900Z

something doesn’t look quite right there

2019-11-16T09:22:32.346200Z

or maybe I’m not sure what you are doing

2019-11-16T09:40:34.347500Z

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

2019-11-16T09:44:40.347700Z

[(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]