From 39b67ea455f44f52f4c809f8c215ceccdbe32679 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Mon, 1 Apr 2013 22:30:47 +0900 Subject: [PATCH] Reducing primitive errors to warnings. Should add an option to escalate all warnings to errors. --- eval.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/eval.c b/eval.c index 8da49a51..36bff64a 100644 --- a/eval.c +++ b/eval.c @@ -961,17 +961,19 @@ static sexp analyze (sexp ctx, sexp object) { } else if (sexp_opcodep(op)) { res = sexp_length(ctx, sexp_cdr(x)); if (sexp_unbox_fixnum(res) < sexp_opcode_num_args(op)) { - res = sexp_compile_error(ctx, "not enough args for opcode", x); + sexp_warn(ctx, "not enough args for opcode: ", x); + op = analyze_var_ref(ctx, sexp_car(x), NULL); } else if ((sexp_unbox_fixnum(res) > sexp_opcode_num_args(op)) && (! sexp_opcode_variadic_p(op))) { - res = sexp_compile_error(ctx, "too many args for opcode", x); - } else { - res = analyze_app(ctx, sexp_cdr(x)); - if (! sexp_exceptionp(res)) { - sexp_push(ctx, res, op); - if (sexp_pairp(res)) - sexp_pair_source(res) = sexp_pair_source(x); - } + sexp_warn(ctx, "too many args for opcode: ", x); + op = analyze_var_ref(ctx, sexp_car(x), NULL); + } + res = analyze_app(ctx, sexp_cdr(x)); + if (! sexp_exceptionp(res)) { + /* push op, which will be a direct opcode if the call is valid */ + sexp_push(ctx, res, op); + if (sexp_pairp(res)) + sexp_pair_source(res) = sexp_pair_source(x); } } else { res = analyze_app(ctx, x);