Fix let rebind bug.
This commit is contained in:
parent
4b0e318997
commit
8c79015b40
@ -305,6 +305,7 @@ as can nested let forms.
|
||||
(macro-error bindings "let bindings must be paired"))
|
||||
(setv g!let (gensym 'let)
|
||||
replacements (OrderedDict)
|
||||
keys []
|
||||
values [])
|
||||
(defn expander [symbol]
|
||||
(.get replacements symbol symbol))
|
||||
@ -315,10 +316,11 @@ as can nested let forms.
|
||||
(macro-error k "binding target may not contain a dot")))
|
||||
(.append values (symbolexpand (macroexpand-all v &name)
|
||||
expander))
|
||||
(assoc replacements k `(get ~g!let ~(name k))))
|
||||
(.append keys `(get ~g!let ~(name k)))
|
||||
(assoc replacements k (last keys)))
|
||||
`(do
|
||||
(setv ~g!let {}
|
||||
~@(interleave (.values replacements) values))
|
||||
~@(interleave keys values))
|
||||
~@(symbolexpand (macroexpand-all body &name)
|
||||
expander)))
|
||||
|
||||
|
@ -329,3 +329,12 @@
|
||||
3))
|
||||
(assert (= b 3))
|
||||
(assert (= c 3))))
|
||||
|
||||
(defn test-let-rebind []
|
||||
(let [x "foo"
|
||||
y "bar"
|
||||
x (+ x y)
|
||||
y (+ y x)
|
||||
x (+ x x)]
|
||||
(assert (= x "foobarfoobar"))
|
||||
(assert (= y "barfoobar"))))
|
||||
|
Loading…
Reference in New Issue
Block a user