Skip to content

Commit

Permalink
[#384] defn should not introduce local for name in body
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Aug 25, 2020
1 parent 476f334 commit 0fdb958
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/sci/impl/analyzer.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,8 @@
macro? (assoc :macro true)))
f (assoc f
:sci/macro macro?
:sci.impl/fn-name fn-name)]
:sci.impl/fn-name fn-name
:sci.impl/var true)]
(mark-eval-call (list 'def fn-name f))))

(defn expand-comment
Expand Down
13 changes: 8 additions & 5 deletions src/sci/impl/fns.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,16 @@
(>= arity min-var-args-arity)))
f))) arities))

(defn eval-fn [ctx interpret eval-do* {:sci.impl/keys [fn-bodies fn-name] :as f}]
(defn eval-fn [ctx interpret eval-do* {:sci.impl/keys [fn-bodies fn-name
var] :as f}]
(let [macro? (:sci/macro f)
self-ref (atom nil)
call-self (fn [& args]
(apply @self-ref args))
ctx (if fn-name (assoc-in ctx [:bindings fn-name] call-self)
ctx)
ctx (if (and (not var)
fn-name)
(assoc-in ctx [:bindings fn-name]
(fn call-self [& args]
(apply @self-ref args)))
ctx)
single-arity? (= 1 (count fn-bodies))
f (if single-arity?
(parse-fn-args+body ctx interpret eval-do* (first fn-bodies) fn-name macro? false)
Expand Down

0 comments on commit 0fdb958

Please sign in to comment.