Allow (del) without arguments

To mirror the behaviour of (setv), allow an empty (del) too: one that
shall return nil. Closes #905.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
This commit is contained in:
Gergely Nagy 2015-08-18 08:51:09 +02:00
parent 649dd38040
commit e0f5d54a2f
No known key found for this signature in database
GPG Key ID: 0A083C5F06E0DD42
2 changed files with 10 additions and 3 deletions

View File

@ -1298,9 +1298,15 @@ class HyASTCompiler(object):
return ret
@builds("del")
@checkargs(min=1)
def compile_del_expression(self, expr):
expr.pop(0)
root = expr.pop(0)
if not expr:
result = Result()
result += ast.Name(id='None', ctx=ast.Load(),
lineno=root.start_line,
col_offset=root.start_column)
return result
ld_targets, ret, _ = self._compile_collect(expr)
del_targets = []

View File

@ -1092,7 +1092,8 @@
(del (get test 4))
(assert (= test [0 1 2 3]))
(del (get test 2))
(assert (= test [0 1 3])))
(assert (= test [0 1 3]))
(assert (= (del) nil)))
(defn test-macroexpand []