From e661ad72cae4e63bcc431986843ce76121d5773a Mon Sep 17 00:00:00 2001 From: Strigoides Date: Sat, 27 Apr 2013 00:49:02 +1200 Subject: [PATCH] Fix COND for clauses with length 1 (COND (1)) should return 1 --- src/boot.lisp | 10 ++++++---- tests/conditionals.lisp | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/boot.lisp b/src/boot.lisp index 40ae705..d30fb79 100644 --- a/src/boot.lisp +++ b/src/boot.lisp @@ -215,10 +215,12 @@ (if (null clausules) nil (if (eq (caar clausules) t) - `(progn ,@(cdar clausules)) - `(if ,(caar clausules) - (progn ,@(cdar clausules)) - (cond ,@(cdr clausules)))))) + `(progn ,@(cdar clausules)) + `(if ,(caar clausules) + ,(if (null (cdar clausules)) + (caar clausules) + `(progn ,@(cdar clausules))) + (cond ,@(cdr clausules)))))) (defmacro case (form &rest clausules) (let ((!form (gensym))) diff --git a/tests/conditionals.lisp b/tests/conditionals.lisp index 9a73dc5..693fbba 100644 --- a/tests/conditionals.lisp +++ b/tests/conditionals.lisp @@ -8,6 +8,7 @@ ; COND (test (eql nil (cond))) +(test (= 1 (cond (1)))) (test (= 2 (cond (1 2)))) (test (= 3 (cond (nil 1) (2 3)))) (test (eql nil (cond (nil 1) (nil 2)))) -- 1.7.10.4