summaryrefslogtreecommitdiff
path: root/test-suite
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2017-02-07 09:28:39 +0100
committerAndy Wingo <wingo@pobox.com>2017-02-07 09:57:55 +0100
commit498f3f95684361f3591106a8f9cb9065fd649288 (patch)
tree70a8e33d1ea25c54c273a3cbe347010403dfb07c /test-suite
parent81e9a128c146ccd495846ecbf664b3fd2855baf1 (diff)
Avoid stacks in dynamically-bound values
* libguile/dynstack.h: * libguile/dynstack.c (scm_dynstack_find_old_fluid_value): New function. * libguile/fluids.c (saved_dynamic_state_ref): New helper. (scm_fluid_ref): Fix docstring. (scm_fluid_ref_star): New function allowing access to previous values for a fluid. (scm_dynamic_state_ref): New internal function. * libguile/fluids.h: Add scm_fluid_ref_star and scm_dynamic_state_ref. * libguile/stacks.c (scm_stack_id): Adapt to %stacks not being a chain. * libguile/throw.c (catch, throw_without_pre_unwind): Adapt to %exception-handlers not being a chain. * module/ice-9/boot-9.scm (catch, dispatch-exception): Instead of having %exception-handlers be a chain, use fluid-ref* to access the chain that is in place at the time the exception is thrown. Prevents unintended undelimited capture of the current exception handler stack by a delimited "catch". (%start-stack): Similarly, don't be a chain. * module/system/repl/debug.scm (frame->stack-vector): * module/system/repl/error-handling.scm (call-with-error-handling): * module/ice-9/save-stack.scm (save-stack): Adapt to %stacks not being a chain. * test-suite/tests/exceptions.test ("delimited exception handlers"): Add tests. * doc/ref/api-control.texi (Fluids and Dynamic States): Add docs.
Diffstat (limited to 'test-suite')
-rw-r--r--test-suite/tests/exceptions.test30
1 files changed, 29 insertions, 1 deletions
diff --git a/test-suite/tests/exceptions.test b/test-suite/tests/exceptions.test
index a839b68de..391a19dca 100644
--- a/test-suite/tests/exceptions.test
+++ b/test-suite/tests/exceptions.test
@@ -16,7 +16,8 @@
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-(use-modules (test-suite lib))
+(define-module (test-suite exceptions)
+ #:use-module (test-suite lib))
(define-syntax-parameter push
(lambda (stx)
@@ -365,3 +366,30 @@
;; (not (eval `(,false-if-exception (,error "xxx"))
;; empty-environment))))
)
+
+(with-test-prefix "delimited exception handlers"
+ (define (catch* key thunk)
+ (let ((tag (make-prompt-tag)))
+ (call-with-prompt tag
+ (lambda ()
+ (catch key
+ (lambda ()
+ (abort-to-prompt tag)
+ (thunk))
+ (lambda args args)))
+ (lambda (k) k))))
+ (pass-if-equal '(foo)
+ (let ((thunk (catch* 'foo (lambda () (throw 'foo)))))
+ (thunk)))
+ (pass-if-equal '(foo)
+ (let* ((thunk1 (catch* 'foo (lambda () (throw 'foo))))
+ (thunk2 (catch* 'bar (lambda () (thunk1)))))
+ (thunk1)))
+ (pass-if-equal '(foo)
+ (let* ((thunk1 (catch* 'foo (lambda () (throw 'foo))))
+ (thunk2 (catch* 'bar (lambda () (thunk1)))))
+ (thunk2)))
+ (pass-if-equal '(bar)
+ (let* ((thunk1 (catch* 'foo (lambda () (throw 'bar))))
+ (thunk2 (catch* 'bar (lambda () (thunk1)))))
+ (thunk2))))