diff --git a/pkgs/racket-test-core/tests/racket/prompt-tests.rktl b/pkgs/racket-test-core/tests/racket/prompt-tests.rktl index 888706338e..cc2d0f1d1c 100644 --- a/pkgs/racket-test-core/tests/racket/prompt-tests.rktl +++ b/pkgs/racket-test-core/tests/racket/prompt-tests.rktl @@ -1129,6 +1129,55 @@ (test #t continuation-mark-set-first #f 'n) (loop (sub1 n))))))))) +(let () + (define (check call-with-ignored-composable-continuation) + ;; Caputured replacing installed with nested metacontinuations + (let ([k (call-with-continuation-prompt + (lambda () + (with-continuation-mark + 'x + 71 + (call-with-ignored-composable-continuation + (lambda (k2) + (non-tail + (with-continuation-mark + 'x + 72 + ((call-with-composable-continuation + (lambda (k) + (lambda () k)))))))))))]) + (test '(72 71) + 'nested-mc + (with-continuation-mark + 'x 81 + (k (lambda () + (continuation-mark-set->list (current-continuation-marks) 'x)))))) + + ;; Captured not replacing + (let ([k (call-with-continuation-prompt + (lambda () + (non-tail + (with-continuation-mark + 'x + 71 + (call-with-ignored-composable-continuation + (lambda (k2) + (non-tail + (with-continuation-mark + 'x + 72 + ((call-with-composable-continuation + (lambda (k) + (lambda () k))))))))))))]) + (test '(72 71 81) + 'nested-mc + (with-continuation-mark + 'x 81 + (k (lambda () + (continuation-mark-set->list (current-continuation-marks) 'x))))))) + (check call-with-composable-continuation) + (check (lambda (proc) (proc #f)))) + ;; ---------------------------------------- ;; Olivier Danvy's traversal diff --git a/racket/src/racket/src/fun.c b/racket/src/racket/src/fun.c index 2ecc783a79..a8de261f6c 100644 --- a/racket/src/racket/src/fun.c +++ b/racket/src/racket/src/fun.c @@ -5368,9 +5368,9 @@ void prune_cont_marks(Scheme_Meta_Continuation *resume_mc, Scheme_Cont *cont, Sc return; } - for (pos = cont->cont_mark_total, num_coverlap = 0; - pos--; - num_coverlap++) { + for (pos = 0, num_coverlap = 0; + pos < cont->cont_mark_total; + num_coverlap++, pos++) { if (cont->cont_mark_stack_copied[pos].pos != (cont->cont_mark_pos_bottom + 2)) break; } @@ -5399,7 +5399,7 @@ void prune_cont_marks(Scheme_Meta_Continuation *resume_mc, Scheme_Cont *cont, Sc scheme_hash_set(ht, SCHEME_VEC_ELS(extra_marks)[i], val); } } - for (pos = cont->cont_mark_total - 1, i = 0; i < num_coverlap; i++, pos--) { + for (pos = 0, i = 0; i < num_coverlap; i++, pos++) { scheme_hash_set(ht, cont->cont_mark_stack_copied[pos].key, NULL); @@ -8456,10 +8456,6 @@ scheme_extract_one_cc_mark_with_meta(Scheme_Object *mark_set, Scheme_Object *key while (chain) { if (chain->key == key) if (key_arg != key) - /* - * TODO: is this the only name that this procedure is called as - * publicly? - */ return scheme_chaperone_do_continuation_mark("continuation-mark-set-first", 1, key_arg, chain->val); else