>From 5a8c194195b25ca51a3429944baa410626b90026 Mon Sep 17 00:00:00 2001 From: Evan Hanson Date: Wed, 27 Nov 2013 16:11:20 +1300 Subject: [PATCH] Expand cond clauses with constant tests and no expressions to the test value --- expand.scm | 4 +++- tests/r7rs-tests.scm | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/expand.scm b/expand.scm index a80eeff..d1a16a0 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 670e959..942b4f3 100644 --- a/tests/r7rs-tests.scm +++ b/tests/r7rs-tests.scm @@ -59,6 +59,10 @@ (SECTION 4 2 1) +;; cond clause with only +(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)))) -- 1.7.10.4