>From 403996a816acf50480ceb83d0f8b225c838b0996 Mon Sep 17 00:00:00 2001 From: Peter Bex Date: Fri, 13 Dec 2013 21:50:25 +0100 Subject: [PATCH] Fix #1080 We now simply check whether an "else"-clause was generated before we generate a catchall else-clause. It's a bit dirty, but it works... --- chicken-syntax.scm | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/chicken-syntax.scm b/chicken-syntax.scm index 112a078..5e88bba 100644 --- a/chicken-syntax.scm +++ b/chicken-syntax.scm @@ -884,23 +884,26 @@ (%memv (r 'memv)) (%else (r 'else))) (define (parse-clause c) - (let* ([var (and (symbol? (car c)) (car c))] - [kinds (if var (cadr c) (car c))] - [body (if var (cddr c) (cdr c))] ) + (let* ((var (and (symbol? (car c)) (car c))) + (kinds (if var (cadr c) (car c))) + (body (if var + `(##core#let ((,var ,exvar)) ,@(cddr c)) + `(##core#let () ,@(cdr c))))) (if (null? kinds) - `(,%else - ,(if var - `(##core#let ([,var ,exvar]) ,@body) - `(##core#let () ,@body) ) ) - `((,%and ,kvar ,@(map (lambda (k) `(,%memv (##core#quote ,k) ,kvar)) kinds)) - ,(if var - `(##core#let ([,var ,exvar]) ,@body) - `(##core#let () ,@body) ) ) ) ) ) + `(,%else ,body) + `((,%and ,kvar ,@(map (lambda (k) + `(,%memv (##core#quote ,k) ,kvar)) kinds)) + ,body ) ) ) ) `(,(r 'handle-exceptions) ,exvar - (##core#let ([,kvar (,%and (##sys#structure? ,exvar (##core#quote condition) ) - (##sys#slot ,exvar 1))]) - (,(r 'cond) ,@(map parse-clause (cddr form)) - (,%else (##sys#signal ,exvar)) ) ) + (##core#let ((,kvar (,%and (##sys#structure? ,exvar + (##core#quote condition)) + (##sys#slot ,exvar 1)))) + ,(let ((clauses (map parse-clause (cddr form)))) + `(,(r 'cond) + ,@clauses + ,@(if (assq %else clauses) + `() ; Don't generate two else clauses + `((,%else (##sys#signal ,exvar)))) )) ) ,(cadr form)))))) -- 1.7.10.4