diff --git a/pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl b/pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl index 9c30adff74..2e494a6dd9 100644 --- a/pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl +++ b/pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl @@ -2248,7 +2248,17 @@ (list (c? (c-q (c 1 2 3)))) 5))) - +(test-comp `(lambda (b) + (let ([v (unbox b)]) + (with-continuation-mark 'x 'y (unbox v)))) + `(lambda (b) + (with-continuation-mark 'x 'y (unbox (unbox b)))) + #f) +(test-comp `(lambda (b) + (let ([v (box b)]) + (with-continuation-mark 'x 'y (box v)))) + `(lambda (b) + (with-continuation-mark 'x 'y (box (box b))))) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Check splitting of definitions diff --git a/racket/src/racket/src/optimize.c b/racket/src/racket/src/optimize.c index ad6e74ff19..c67f87a6cb 100644 --- a/racket/src/racket/src/optimize.c +++ b/racket/src/racket/src/optimize.c @@ -3252,6 +3252,11 @@ static Scheme_Object *optimize_wcm(Scheme_Object *o, Optimize_Info *info, int co v = scheme_optimize_expr(wcm->val, info, 0); + /* The presence of a key can be detected by other expressions, + to increment vclock to prevent expressions incorrectly + moving under the mark: */ + info->vclock++; + b = scheme_optimize_expr(wcm->body, info, scheme_optimize_tail_context(context)); if (omittable_key(k, info)