use-before-definition analysis: fix checking of with-cont-mark form

Similar to the `set!` problem.
This commit is contained in:
Matthew Flatt 2014-08-01 10:52:27 +01:00
parent 6efac46b3f
commit ac428f89fa
2 changed files with 30 additions and 2 deletions

View File

@ -127,5 +127,27 @@
b) b)
letrec-exn?) letrec-exn?)
(err/rt-test
(letrec ([b (with-continuation-mark
'x
(lambda () c)
((continuation-mark-set-first
(current-continuation-marks)
'x)))]
[c 1])
c)
letrec-exn?)
(err/rt-test
(letrec ([b (with-continuation-mark
'x
(lambda () c)
(+ (random)
((continuation-mark-set-first
(current-continuation-marks)
'x))))]
[c 1])
c)
letrec-exn?)
(report-errs) (report-errs)

View File

@ -738,14 +738,20 @@ static Scheme_Object *letrec_check_wcm(Scheme_Object *o, Letrec_Check_Frame *fra
Scheme_Object *uvars, Scheme_Object *pvars, Scheme_Object *pos) Scheme_Object *uvars, Scheme_Object *pvars, Scheme_Object *pos)
{ {
Scheme_With_Continuation_Mark *wcm; Scheme_With_Continuation_Mark *wcm;
Scheme_Object *val; Scheme_Object *val, *val_uvars, *val_pvars, *val_pos;
wcm = (Scheme_With_Continuation_Mark *)o; wcm = (Scheme_With_Continuation_Mark *)o;
val = letrec_check_expr(wcm->key, frame, uvars, pvars, pos); val = letrec_check_expr(wcm->key, frame, uvars, pvars, pos);
wcm->key = val; wcm->key = val;
val = letrec_check_expr(wcm->val, frame, uvars, pvars, pos);
/* Since a value can be accessed through `current-continuaton-marks`... */
val_uvars = merge_vars(uvars, pvars);
val_pvars = rem_vars(pvars);
val_pos = scheme_false;
val = letrec_check_expr(wcm->val, frame, val_uvars, val_pvars, val_pos);
wcm->val = val; wcm->val = val;
val = letrec_check_expr(wcm->body, frame, uvars, pvars, pos); val = letrec_check_expr(wcm->body, frame, uvars, pvars, pos);
wcm->body = val; wcm->body = val;