 
 (defn repl
   "Note - repl will reload core.cljs every time, even if supplied old repl-env"
-  [repl-env & {:keys [verbose]}]
+  [repl-env & {:keys [verbose warn-on-undeclared]}]
   (prn "Type: " :cljs/quit " to quit")
   (binding [*cljs-ns* 'cljs.user
-            *cljs-verbose* verbose]
+            *cljs-verbose* verbose
+            *cljs-warn-on-undeclared* warn-on-undeclared]
     (let [env {:context :statement :locals {}}]
       (load-file repl-env "cljs/core.cljs")
       (eval1 repl-env (assoc env :ns (@namespaces *cljs-ns*))

(comp/repl repl-env)
;having problems?, try verbose mode
(comp/repl repl-env :verbose true)

(test-stuff)
(+ 1 2 3)

goog.require = function(rule){Packages.clojure.lang.RT[\"var\"](\"cljs.compiler\",\"goog-require\").invoke(goog.global.cljs_javascript_engine, rule);}
")

(defn confirm-var-exists [env prefix suffix]
  (when *cljs-warn-on-undeclared*
    (let [crnt-ns (-> env :ns :name)]
      (when (= prefix crnt-ns)
        (when-not (-> @namespaces crnt-ns :defs suffix)
          (binding [*out* *err*]
            (println
              (str "WARNING: Use of undeclared Var " prefix "/" suffix
                   (when (:line env)
                     (str " at line " (:line env)))))))))))

(defn resolve-ns-alias [env name]
  (let [sym (symbol name)]
    (get (:requires (:ns env)) sym sym)))

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

         (namespace sym)
         (let [ns (namespace sym)
               ns (if (= "clojure.core" ns) "cljs.core" ns)
               full-ns (resolve-ns-alias env ns)]
           (confirm-var-exists env full-ns (symbol (name sym)))
           (symbol (str full-ns "." (munge (name sym)))))

         (.contains s ".")
         (munge (let [idx (.indexOf s ".")
                      prefix (symbol (subs s 0 idx))
                      suffix (subs s idx)
                      lb (-> env :locals prefix)]
                  (if lb
                    (symbol (str (:name lb) suffix))
                    (do
                      (confirm-var-exists env prefix (symbol suffix))
                      sym))))

         :else
         (let [full-ns (if (get (:defs (@namespaces 'cljs.core)) sym)
                         'cljs.core
                         (-> env :ns :name))]
           (confirm-var-exists env full-ns sym)
           (munge (symbol (str full-ns "." (munge (name sym)))))))]
    {:name nm}))

(defn resolve-var [env sym]
  (let [s (str sym)
