Skip to content

Commit 7e7035c

Browse files
committed
Fix bug in letfn parser; add all bindings to env
Signed-off-by: James Hamlin <jfhamlin@gmail.com>
1 parent 9b51976 commit 7e7035c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

pkg/compiler/analyze.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ func (a *Analyzer) parseLetfnStar(form interface{}, env Env) (*ast.Node, error)
11111111
}
11121112
e := env
11131113
for name, bind := range bindsMap {
1114-
e = updateIn(env, vec(KWLocals), merge, NewMap(name, bind)).(Env)
1114+
e = updateIn(e, vec(KWLocals), merge, NewMap(name, bind)).(Env)
11151115
}
11161116
var binds []*ast.Node
11171117
for name, bind := range bindsMap {

test/glojure/test_glojure/lcm.glj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
(ns glojure.test-glojure.lcm
2+
(:use glojure.test))
3+
4+
(defn lcm
5+
[& x]
6+
(letfn [(gcd [a b] (if (zero? b) a (gcd b (mod a b))))
7+
(lcm [a b] (/ (* a b) (gcd a b)))]
8+
(reduce lcm x)))
9+
10+
(deftest lcmtest
11+
(is (= 6 (lcm 2 3))
12+
"lcm of 2 and 3 is 6"))
13+
14+
(run-tests)

0 commit comments

Comments
 (0)