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.
This commit is contained in:
Jesse D. McDonald 2010-04-15 00:19:52 -05:00
parent 8e147f7989
commit 6b51229c48
1 changed files with 3 additions and 1 deletions

View File

@ -35,7 +35,9 @@
(if (or (not (pair? subform)) (if (or (not (pair? subform))
(memq (first subform) '(%apply %car %cdr %cons %bind %if))) (memq (first subform) '(%apply %car %cdr %cons %bind %if)))
(list (simplify-set! `(set! ,(second form) ,subform))) (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))) (cddr value-form)))
`(%set! ,(second form) ,value-form)))) `(%set! ,(second form) ,value-form))))