 
          :else
          (munge (symbol (str
-                         (if (get (:defs (@namespaces 'cljs.core)) sym)
+                         (if (core-name? env sym)
                            'cljs.core
                            (-> env :ns :name))
                          "." (munge (name sym))))))]


(defmethod parse 'ns
  [_ env [_ name & args] _]
  (let [{requires :require requires-macros :require-macros :as params}
        (reduce (fn [m [k & libs]]
                  (assoc m k (into {}
                                   (map (fn [[lib as alias]]
                                          (assert (and alias (= :as as)) "Only [lib.ns :as alias] form supported")
                                          [alias lib])
                                        libs))))
                {} args)]
    (set! *cljs-ns* name)
    (require 'cljs.core)
    (doseq [nsym (vals requires-macros)]
      (clojure.core/require nsym))
    (swap! namespaces #(-> %
                           (assoc-in [name :name] name)
                           (assoc-in [name :requires] requires)
                           (assoc-in [name :requires-macros]
                                     (into {} (map (fn [[alias nsym]]
                                                     [alias (find-ns nsym)])
                                                   requires-macros)))))
    {:env env :op :ns :name name :requires requires :requires-macros requires-macros}))

(defmethod parse 'deftype*
  [_ env [_ tsym fields] _]

  (let [sym (symbol name)]
    (get (:requires (:ns env)) sym sym)))

(defn core-name?
  "Is sym visible from core in the current compilation namespace?"
  [env sym]
  (and (get (:defs (@namespaces 'cljs.core)) sym)
       (not (contains? (-> env :ns :excludes) sym))))

(defn resolve-existing-var [env sym]
  (let [s (str sym)
        lb (-> env :locals sym)
