From 50063d45233df9a537f6e54d37fe062bf0346a4f Mon Sep 17 00:00:00 2001 From: Lassi Kortela Date: Wed, 28 Aug 2019 21:19:39 +0300 Subject: [PATCH] Cause compiler error when (if ...) has spurious args --- scheme-core/compiler.scm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scheme-core/compiler.scm b/scheme-core/compiler.scm index 1a72244..2a0bf55 100644 --- a/scheme-core/compiler.scm +++ b/scheme-core/compiler.scm @@ -262,9 +262,12 @@ (endl (make-label g)) (test (cadr x)) (then (caddr x)) - (else (if (pair? (cdddr x)) - (cadddr x) - (void)))) + (else (cond ((null? (cdddr x)) + (void)) + ((null? (cddddr x)) + (cadddr x)) + (else + (error "compile error: if expects 2-3 arguments."))))) (cond ((eq? test #t) (compile-in g env tail? then)) ((eq? test #f)