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"))
|
(macro-error bindings "let bindings must be paired"))
|
||||||
(setv g!let (gensym 'let)
|
(setv g!let (gensym 'let)
|
||||||
replacements (OrderedDict)
|
replacements (OrderedDict)
|
||||||
|
keys []
|
||||||
values [])
|
values [])
|
||||||
(defn expander [symbol]
|
(defn expander [symbol]
|
||||||
(.get replacements symbol symbol))
|
(.get replacements symbol symbol))
|
||||||
@ -315,10 +316,11 @@ as can nested let forms.
|
|||||||
(macro-error k "binding target may not contain a dot")))
|
(macro-error k "binding target may not contain a dot")))
|
||||||
(.append values (symbolexpand (macroexpand-all v &name)
|
(.append values (symbolexpand (macroexpand-all v &name)
|
||||||
expander))
|
expander))
|
||||||
(assoc replacements k `(get ~g!let ~(name k))))
|
(.append keys `(get ~g!let ~(name k)))
|
||||||
|
(assoc replacements k (last keys)))
|
||||||
`(do
|
`(do
|
||||||
(setv ~g!let {}
|
(setv ~g!let {}
|
||||||
~@(interleave (.values replacements) values))
|
~@(interleave keys values))
|
||||||
~@(symbolexpand (macroexpand-all body &name)
|
~@(symbolexpand (macroexpand-all body &name)
|
||||||
expander)))
|
expander)))
|
||||||
|
|
||||||
|
@ -329,3 +329,12 @@
|
|||||||
3))
|
3))
|
||||||
(assert (= b 3))
|
(assert (= b 3))
|
||||||
(assert (= c 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