set the value of empty hy expression to []

This commit is contained in:
Guillermo Vaya 2013-06-26 01:40:10 +02:00 committed by Nicolas Dandrimont
parent 9b45dd4ffe
commit 7b7b953410
2 changed files with 10 additions and 1 deletions

View File

@ -70,7 +70,12 @@ _wrappers = {
def process(tree, module_name): def process(tree, module_name):
if isinstance(tree, HyExpression): if isinstance(tree, HyExpression):
try:
fn = tree[0] fn = tree[0]
except IndexError:
ntree = HyList()
ntree.replace(tree)
return ntree
if fn in ("quote", "quasiquote"): if fn in ("quote", "quasiquote"):
return tree return tree
ntree = HyExpression( ntree = HyExpression(

View File

@ -755,3 +755,7 @@
(continue)) (continue))
(.append y x)) (.append y x))
(assert (= y [5]))) (assert (= y [5])))
(defn test-empty-list []
"Evaluate an empty list to a []"
(assert (= () [])))