 (defn emit-fn-method
   [{:keys [gthis name variadic params statements ret env recurs]}]
   (emit-wrap env
-             (print (str "(function " name "(" (comma-sep params) "){\n"))
+             (print (str "(function " name "(" (comma-sep
+                                                (if variadic
+                                                  (concat (butlast params) ['var_args])
+                                                  params)) "){\n"))
              (when gthis
                (println (str "var " gthis " = this;")))
              (when variadic

        (println (str "var " name " = null;"))
        (doseq [[n meth] ms]
          (println (str "var " n " = " (with-out-str (emit-fn-method meth)) ";")))
        (println (str name " = function(" (comma-sep maxparams) "){"))
        (println "switch(arguments.length){")
        (doseq [[n meth] ms]
          (if (:variadic meth)

(defmethod emit :def
  [{:keys [name init env]}]
  (when init
    (when (:jsdoc init)
      (println "/**")
      (doseq [e (:jsdoc init)]
        (when e
          (println "*" e)))
      (println "*/"))
    (print name)
    (print (str " = " (emits init)))
    (when-not (= :expr (:context env)) (print ";\n"))))
