Skip to content

Commit 9160a3e

Browse files
committed
Fix abort-current-continuation's denv restoration bug
#1227
1 parent cd35208 commit 9160a3e

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

src/vm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3191,8 +3191,10 @@ ScmObj Scm_VMAbortCurrentContinuation(ScmObj promptTag, ScmObj args)
31913191
SCM_ASSERT(pd->dummy == SCM_VM_INSN(SCM_VM_RET));
31923192
ScmObj targetHandlers = pd->dynamicHandlers;
31933193

3194-
/* Discard continuation up to abortTo frame. */
3194+
/* Discard continuation, and reinstate abortTo frame and its
3195+
dynamic environment. */
31953196
CONT = abortTo;
3197+
DENV = abortTo->denv;
31963198

31973199
ScmObj currentHandlers = get_dynamic_handlers(vm);
31983200
if (targetHandlers != currentHandlers && SCM_PAIRP(currentHandlers)) {

tests/continuation.scm

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,23 @@
505505
(^[] (car 1))))
506506
tag list)))
507507

508+
;; https://github.com/shirok/Gauche/issues/1227
509+
(let ([tag1 (make-continuation-prompt-tag 'tag)])
510+
(test* "abort-current-continuation (wrong number of arguments)"
511+
(test-error <error> #/wrong number of arguments/)
512+
(let ([r '()])
513+
(call-with-continuation-prompt
514+
(^[]
515+
(dynamic-wind
516+
(^[] (push! r 'before))
517+
(^[]
518+
(guard (e [else (push! r 'guard)])
519+
(push! r 'body)
520+
(abort-current-continuation tag1 'one 'two)))
521+
(^[] (push! r 'after))))
522+
tag1
523+
(^[x] (push! r x))))))
524+
508525
;;-----------------------------------------------------------------------
509526
;; Parameterizations
510527
;;

0 commit comments

Comments
 (0)