Allow variable without value in `let' declaration
Fixes issue #138 Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
aadf47ed99
commit
07860b5ce6
@ -133,12 +133,17 @@ def rest_macro(tree):
|
||||
@macro("let")
|
||||
def let_macro(tree):
|
||||
tree.pop(0) # "let"
|
||||
ret = tree.pop(0) # vars
|
||||
variables = tree.pop(0)
|
||||
# tree is now the body
|
||||
expr = HyExpression([HySymbol("fn"), HyList([])])
|
||||
|
||||
for var in ret:
|
||||
expr.append(HyExpression([HySymbol("setf"), var[0], var[1]]))
|
||||
for var in variables:
|
||||
if isinstance(var, list):
|
||||
expr.append(HyExpression([HySymbol("setf"),
|
||||
var[0], var[1]]))
|
||||
else:
|
||||
expr.append(HyExpression([HySymbol("setf"),
|
||||
var, HySymbol("None")]))
|
||||
|
||||
for stmt in tree:
|
||||
expr.append(stmt)
|
||||
|
@ -479,7 +479,8 @@
|
||||
|
||||
(defn test-let []
|
||||
"NATIVE: test let works rightish"
|
||||
(assert (= (let [[x 1] [y 2] [z 3]] (+ x y z)) 6)))
|
||||
(assert (= (let [[x 1] [y 2] [z 3]] (+ x y z)) 6))
|
||||
(assert (= (let [[x 1] a [y 2] b] (if a 1 2)) 2)))
|
||||
|
||||
|
||||
(defn test-if-mangler []
|
||||
|
Loading…
x
Reference in New Issue
Block a user