~ chicken-core (chicken-5) 6a389c5c6fee611f2e4b54b1cee6873e52c38e7a
commit 6a389c5c6fee611f2e4b54b1cee6873e52c38e7a
Author: Evan Hanson <evhan@foldling.org>
AuthorDate: Wed Nov 27 16:11:20 2013 +1300
Commit: Peter Bex <peter.bex@xs4all.nl>
CommitDate: Wed Nov 27 16:49:50 2013 +0100
Expand cond clauses with constant tests and no expressions to the test value
Signed-off-by: Peter Bex <peter.bex@xs4all.nl>
diff --git a/expand.scm b/expand.scm
index a80eeff3..d1a16a04 100644
--- a/expand.scm
+++ b/expand.scm
@@ -1161,7 +1161,9 @@
(and (pair? (car clause))
(c (r 'quote) (caar clause))))
(expand rclauses (strip-syntax (car clause)))
- `(##core#begin ,@(cdr clause)))
+ (if (null? (cdr clause))
+ (car clause)
+ `(##core#begin ,@(cdr clause))))
((null? (cdr clause))
`(,%or ,(car clause) ,(expand rclauses #f)))
((and (fx= (length clause) 3)
diff --git a/tests/r7rs-tests.scm b/tests/r7rs-tests.scm
index 670e9593..942b4f33 100644
--- a/tests/r7rs-tests.scm
+++ b/tests/r7rs-tests.scm
@@ -59,6 +59,10 @@
(SECTION 4 2 1)
+;; cond clause with only <test>
+(test 1 (lambda () (cond (1))))
+(test 'foo (lambda () (cond ('foo))))
+
;; case with => clause
(test "a" (lambda () (case 'a ((a) => symbol->string))))
(test "a" (lambda () (case 'a (else => symbol->string))))
Trap