bytecode compiler: fix for call-with-immediate-continuation-mark

The converstion from calling `call-with-immediate-continuation-mark`
to an internal `with-immediate-continuation-mark` form did not handler
a mutable argument variable.
This commit is contained in:
Matthew Flatt 2018-04-23 21:12:21 -06:00
parent 3531cb24f4
commit 88d8ba00e0
2 changed files with 22 additions and 0 deletions

View File

@ -6300,6 +6300,18 @@
(lambda () (lambda ()
(list-cmp348))) (list-cmp348)))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Make sure conversion to internal `with-immediate-continuation-mark`
;; correctly handles mutable variables
(test #f
'wicm
(call-with-immediate-continuation-mark
'hello
(lambda (m)
(set! m m)
m)))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(report-errs) (report-errs)

View File

@ -778,6 +778,16 @@ with_immed_mark_resolve(Scheme_Object *data, Resolve_Info *orig_rslv)
var->resolve.lex_depth = rslv->current_lex_depth; var->resolve.lex_depth = rslv->current_lex_depth;
e = resolve_expr(SCHEME_CDR(wcm->body), rslv); e = resolve_expr(SCHEME_CDR(wcm->body), rslv);
if (var->mutated) {
Scheme_Object *bcode;
bcode = scheme_alloc_object();
bcode->type = scheme_boxenv_type;
SCHEME_PTR1_VAL(bcode) = scheme_make_integer(0);
SCHEME_PTR2_VAL(bcode) = e;
e = bcode;
}
wcm->body = e; wcm->body = e;
merge_resolve(orig_rslv, rslv); merge_resolve(orig_rslv, rslv);