(defn parse-recur
[[_ & exprs :as form] {:keys [context loop-locals loop-id]
:as env}]
(when-let [error-msg
(cond
(not (isa? context :ctx/return))
"Can only recur from tail position"
(not (= (count exprs) loop-locals))
(str "Mismatched argument count to recur, expected: " loop-locals
" args, had: " (count exprs)))]
(throw (ex-info error-msg
(merge {:exprs exprs
:form form}
(-source-info form env)))))
(let [exprs (mapv (analyze-in-env (ctx env :ctx/expr)) exprs)]
{:op :recur
:env env
:form form
:exprs exprs
:loop-id loop-id
:children [:exprs]}))