                                                (first ret-val))]
                                  `(do (set! ~returned? true)
                                       (set! ~return-value ~ret-val))))
+        nested-block `(~'_ ~@args)
         let-statements (transform (walker #(= "return" (safe-some-> %1 first)))
                                   process-return-stmts
-                                  let-statements)
+                                  nested-block)
         process-returned? (fn [arg]
                             returned?
                             )
         let-statements (transform (walker #(= %1 :returned?)) 
-                                    process-returned? 
-                                    let-statements)
-        expr `(let-mutable ~(vec (into [return-value nil
-                                        returned? false] 
-                                       (apply concat global-var-init-statements 
-                                         (next let-statements)
-                                         )))
-                ~return-value)]
+                                  process-returned? 
+                                  let-statements)
+        init-statements (vec (concat [return-value nil
+                                     returned? false] 
+                                    global-var-init-statements)) 
+        let-statements (into init-statements let-statements)
+        expr `(let-mutable ~let-statements ~return-value)]
     (println "chunk-fn2:" global-var-init-statements)
     expr
     ))

  (let [local-var-init-statements (select 
                                    [ALL #(= (safe-some-> %1 first) :local)]
                                    args) 
        r (do
            (println "local-var-init-statements:" local-var-init-statements)
            (if (seq local-var-init-statements)
            `(let-mutable ~(vec (transform [ALL] #(conj ['_] %1) args)))
            `(do ~@args)))]
    (println "block-fn return:" r)
    r
    ))

   [:explist [:exp [:prefixexp [:var [:Name "g"]]]]]]]]

(pprint (lua-parser (slurp "resources/test/basic1.lua")))
(proteus/let-mutable 
  [G__19303 nil G__19304 false 
   g 55;nil 
   (do (cond true 
             (proteus/let-mutable 
               [l "local_var" 
                luaclj.core/_ (set! l "local_var_modified") 
                luaclj.core/_ (do (set! G__19304 true) (println "setting:" l) (set! G__19303 l))])) 
       (set! g "global_var") (do (set! G__19304 true) (println "g:" g) (set! G__19303 g)))]
  G__19303)
(eval (insta/transform transform-map (lua-parser (slurp "resources/test/basic1.lua"))))
  (try (pprint (insta/transform transform-map (lua-parser (slurp "resources/test/basic1.lua"))))
       (catch Exception ex (clojure.stacktrace/print-stack-trace ex)))
  (pprint tree)
