Reducing primitive errors to warnings.

Should add an option to escalate all warnings to errors.
This commit is contained in:
Alex Shinn 2013-04-01 22:30:47 +09:00
parent 95215e9228
commit 39b67ea455

10
eval.c
View file

@ -961,18 +961,20 @@ static sexp analyze (sexp ctx, sexp object) {
} else if (sexp_opcodep(op)) { } else if (sexp_opcodep(op)) {
res = sexp_length(ctx, sexp_cdr(x)); res = sexp_length(ctx, sexp_cdr(x));
if (sexp_unbox_fixnum(res) < sexp_opcode_num_args(op)) { 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)) } else if ((sexp_unbox_fixnum(res) > sexp_opcode_num_args(op))
&& (! sexp_opcode_variadic_p(op))) { && (! sexp_opcode_variadic_p(op))) {
res = sexp_compile_error(ctx, "too many args for opcode", x); sexp_warn(ctx, "too many args for opcode: ", x);
} else { op = analyze_var_ref(ctx, sexp_car(x), NULL);
}
res = analyze_app(ctx, sexp_cdr(x)); res = analyze_app(ctx, sexp_cdr(x));
if (! sexp_exceptionp(res)) { if (! sexp_exceptionp(res)) {
/* push op, which will be a direct opcode if the call is valid */
sexp_push(ctx, res, op); sexp_push(ctx, res, op);
if (sexp_pairp(res)) if (sexp_pairp(res))
sexp_pair_source(res) = sexp_pair_source(x); sexp_pair_source(res) = sexp_pair_source(x);
} }
}
} else { } else {
res = analyze_app(ctx, x); res = analyze_app(ctx, x);
} }