From 6b51229c485130f5893342a05bc8097b2de23d35 Mon Sep 17 00:00:00 2001 From: Jesse McDonald Date: Thu, 15 Apr 2010 00:19:52 -0500 Subject: [PATCH] Raise an error if (set! ...) is applied to a form without a value. Exception is (%tail-call ...) form, which is permitted simply because (%tail-call ...) transfers control unidirectionally; the enclosing (%set! ...) form wouldn't be run anyway. --- compiler.ss | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler.ss b/compiler.ss index 2fafc97..be7b80f 100755 --- a/compiler.ss +++ b/compiler.ss @@ -35,7 +35,9 @@ (if (or (not (pair? subform)) (memq (first subform) '(%apply %car %cdr %cons %bind %if))) (list (simplify-set! `(set! ,(second form) ,subform))) - (list subform)))) + (if (and (pair? subform) (eq? (first subform) '%tail-call)) + (list subform) ; The %set! wouldn't be executed anyway. + (error "set! used with non-value form:" subform))))) '() (cddr value-form))) `(%set! ,(second form) ,value-form))))