mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-18 21:29:19 +02:00
stop after first compile error in an if (fixes #792)
This commit is contained in:
parent
9a17254536
commit
3080087d8c
1 changed files with 12 additions and 5 deletions
17
eval.c
17
eval.c
|
@ -900,11 +900,18 @@ static sexp analyze_if (sexp ctx, sexp x, int depth) {
|
|||
res = sexp_compile_error(ctx, "too many args to if", x);
|
||||
} else {
|
||||
test = analyze(ctx, sexp_cadr(x), depth, 0);
|
||||
pass = analyze(ctx, sexp_caddr(x), depth, 0);
|
||||
fail_expr = sexp_pairp(sexp_cdddr(x)) ? sexp_cadddr(x) : SEXP_VOID;
|
||||
fail = analyze(ctx, fail_expr, depth, 0);
|
||||
res = (sexp_exceptionp(test) ? test : sexp_exceptionp(pass) ? pass :
|
||||
sexp_exceptionp(fail) ? fail : sexp_make_cnd(ctx, test, pass, fail));
|
||||
if (sexp_exceptionp(test)) {
|
||||
res = test;
|
||||
} else {
|
||||
pass = analyze(ctx, sexp_caddr(x), depth, 0);
|
||||
if (sexp_exceptionp(pass)) {
|
||||
res = pass;
|
||||
} else {
|
||||
fail_expr = sexp_pairp(sexp_cdddr(x)) ? sexp_cadddr(x) : SEXP_VOID;
|
||||
fail = analyze(ctx, fail_expr, depth, 0);
|
||||
res = sexp_exceptionp(fail) ? fail : sexp_make_cnd(ctx, test, pass, fail);
|
||||
}
|
||||
}
|
||||
if (sexp_cndp(res)) sexp_cnd_source(res) = sexp_pair_source(x);
|
||||
}
|
||||
sexp_gc_release3(ctx);
|
||||
|
|
Loading…
Add table
Reference in a new issue