yet more repairs to the interaction of errors and let-values

Continuing the saga that includes 8190a7730d and d1ba9fbb6e, it turns
out that a 0-binding clause as the last one isn't so special after
all. A little later in the optimizer, now that we're sometimes moving
an error to the body, we can't assume that the body can be discard
if an error was detected.
This commit is contained in:
Matthew Flatt 2017-01-20 18:02:33 -07:00
parent d1ba9fbb6e
commit 736cdfb2c1
2 changed files with 25 additions and 2 deletions

View File

@ -3892,6 +3892,21 @@
'(error "oops"))
(test-comp '(letrec-values ([(x y) (error "oops")]) 11)
'(error "oops"))
(test-comp '(let-values (((y) (read)) (() (error "oops"))) 11)
'(let () (begin (read) (error "oops"))))
(test-comp '(let-values (((y) (read)) (() (error "oops"))) 11)
'(let () (begin (read) (error "oops"))))
(test-comp '(let-values ((() (error "oops")) ((x) 9)) 11)
'(error "oops"))
(test-comp '(let-values ((() (error "oops")) (() (values))) 11)
'(error "oops"))
(test-comp '(let-values (((y) (read)) (() (error "oops")) ((x) 9)) 11)
'(let () (begin (read) (error "oops"))))
(test-comp '(let-values (((y) (read)) (() (error "oops")) (() (values))) 11)
'(let () (begin (read) (error "oops"))))
(test-comp '(error "oops")
'(let () (begin (read) (error "oops")))
#f)
(test-comp '(with-continuation-mark
'x 'y

View File

@ -7523,6 +7523,14 @@ static Scheme_Object *optimize_lets(Scheme_Object *form, Optimize_Info *info, in
naya2->value = scheme_false;
naya2 = (Scheme_IR_Let_Value *)naya2->body;
}
if (!pre_body->count && !SCHEME_FALSEP(value)) {
/* Since `value` is not false, this clause must be the one
that is escaping. We'll end up dropping the remaining
clauses and the original body, but we need to keep the
erroring expression. */
escape_body = value;
}
}
if (prev_body)
@ -8060,8 +8068,8 @@ static Scheme_Object *optimize_lets(Scheme_Object *form, Optimize_Info *info, in
if (head->num_clauses)
seq->array[1] = (Scheme_Object *)head;
else if (found_escapes) {
/* don't need the body, because some RHS escapes */
else if (found_escapes && SCHEME_FALSEP(head->body)) {
/* don't need the `#f` for the body, because some RHS escapes */
new_body = ensure_noncm(rhs);
} else
seq->array[1] = head->body;