mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +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);
|
res = sexp_compile_error(ctx, "too many args to if", x);
|
||||||
} else {
|
} else {
|
||||||
test = analyze(ctx, sexp_cadr(x), depth, 0);
|
test = analyze(ctx, sexp_cadr(x), depth, 0);
|
||||||
pass = analyze(ctx, sexp_caddr(x), depth, 0);
|
if (sexp_exceptionp(test)) {
|
||||||
fail_expr = sexp_pairp(sexp_cdddr(x)) ? sexp_cadddr(x) : SEXP_VOID;
|
res = test;
|
||||||
fail = analyze(ctx, fail_expr, depth, 0);
|
} else {
|
||||||
res = (sexp_exceptionp(test) ? test : sexp_exceptionp(pass) ? pass :
|
pass = analyze(ctx, sexp_caddr(x), depth, 0);
|
||||||
sexp_exceptionp(fail) ? fail : sexp_make_cnd(ctx, test, pass, fail));
|
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);
|
if (sexp_cndp(res)) sexp_cnd_source(res) = sexp_pair_source(x);
|
||||||
}
|
}
|
||||||
sexp_gc_release3(ctx);
|
sexp_gc_release3(ctx);
|
||||||
|
|
Loading…
Add table
Reference in a new issue