mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-18 21:29:19 +02:00
Check for valid "rest" parameters in parameter lists
Checks for invalid parameter names and duplicate parameters were being performed on parameter lists, but these checks were not considering any rest parameters. This means that ((lambda (x . x) x) 'foo 'bar) => foo ((lambda (x . 0) x) 'foo 'bar) => foo ((lambda (x . #t) x) 'foo 'bar) => foo ((lambda 0 'foo)) => foo ((lambda #t 'foo)) => foo and so on. Now these all produce errors.
This commit is contained in:
parent
d0b63109e8
commit
439e35da61
1 changed files with 6 additions and 0 deletions
6
eval.c
6
eval.c
|
@ -806,6 +806,12 @@ static sexp analyze_lambda (sexp ctx, sexp x, int depth) {
|
|||
sexp_return(res, sexp_compile_error(ctx, "non-symbol parameter", x));
|
||||
else if (sexp_truep(sexp_memq(ctx, sexp_car(ls), sexp_cdr(ls))))
|
||||
sexp_return(res, sexp_compile_error(ctx, "duplicate parameter", x));
|
||||
if (! sexp_nullp(ls)) {
|
||||
if (! sexp_idp(ls))
|
||||
sexp_return(res, sexp_compile_error(ctx, "non-symbol parameter", x));
|
||||
else if (sexp_truep(sexp_memq(ctx, ls, sexp_cadr(x))))
|
||||
sexp_return(res, sexp_compile_error(ctx, "duplicate parameter", x));
|
||||
}
|
||||
/* build lambda and analyze body */
|
||||
res = sexp_make_lambda(ctx, tmp=sexp_copy_list(ctx, sexp_cadr(x)));
|
||||
if (sexp_exceptionp(res)) sexp_return(res, res);
|
||||
|
|
Loading…
Add table
Reference in a new issue