>From f4c11e965941dfaaa4c9a56ec388535ce87580da Mon Sep 17 00:00:00 2001 From: Evan Hanson Date: Fri, 15 Nov 2013 15:17:26 +1300 Subject: [PATCH] Return the result of EXP from (assert EXP) --- chicken-syntax.scm | 18 ++++++++++-------- tests/scrutiny-2.expected | 4 ++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/chicken-syntax.scm b/chicken-syntax.scm index 29ed89d..112a078 100644 --- a/chicken-syntax.scm +++ b/chicken-syntax.scm @@ -171,17 +171,19 @@ (##sys#check-syntax 'assert form '#(_ 1)) (let* ((exp (cadr form)) (msg-and-args (cddr form)) - (msg (optional msg-and-args "assertion failed"))) + (msg (optional msg-and-args "assertion failed")) + (tmp (r 'tmp))) (when (string? msg) (and-let* ((ln (get-line-number form))) (set! msg (string-append "(" ln ") " msg)))) - `(##core#if (##core#check ,exp) - (##core#undefined) - (##sys#error - ,msg - ,@(if (pair? msg-and-args) - (cdr msg-and-args) - `((##core#quote ,(##sys#strip-syntax exp))))))))))) + `(##core#let ((,tmp ,exp)) + (##core#if (##core#check ,tmp) + ,tmp + (##sys#error + ,msg + ,@(if (pair? msg-and-args) + (cdr msg-and-args) + `((##core#quote ,(##sys#strip-syntax exp)))))))))))) (##sys#extend-macro-environment 'ensure diff --git a/tests/scrutiny-2.expected b/tests/scrutiny-2.expected index 1985dac..10cd844 100644 --- a/tests/scrutiny-2.expected +++ b/tests/scrutiny-2.expected @@ -45,6 +45,10 @@ Note: at toplevel: Note: at toplevel: (scrutiny-tests-2.scm:22) in procedure call to `null?', the predicate is called with an argument of type + `pair' and will always return false + +Note: at toplevel: + (scrutiny-tests-2.scm:22) in procedure call to `null?', the predicate is called with an argument of type `fixnum' and will always return false Note: at toplevel: -- 1.7.10.4