From 175232485d4b41c7f1b221100abf58ddfa8c8187 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 28 Jan 2015 22:20:32 -0800 Subject: * eval.c (get_opt_param_syms): Fix broken function. This was choking on keywords like :env in the lambda list, and failing to handle the nested patterns of macro lambda lists. Failing case: (defmacro x (: opt :env foo)). --- ChangeLog | 7 +++++++ eval.c | 17 ++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index d197bbf6..17da1251 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2015-01-28 Kaz Kylheku + + * eval.c (get_opt_param_syms): Fix broken function. This + was choking on keywords like :env in the lambda list, + and failing to handle the nested patterns of macro + lambda lists. Failing case: (defmacro x (: opt :env foo)). + 2015-01-28 Kaz Kylheku * eval.c (bind_macro_params): Bugfix: the colon argument's special diff --git a/eval.c b/eval.c index 8bc38a4b..7f611589 100644 --- a/eval.c +++ b/eval.c @@ -513,6 +513,7 @@ static val expand_params(val params, val menv) params_ex); } +static val get_param_syms(val params); static val get_opt_param_syms(val params) { @@ -521,18 +522,16 @@ static val get_opt_param_syms(val params) } else if (atom(params)) { return nil; } else { - val form = car(params); + val spec = car(params); - if (atom(form) || !consp(cdr(form))) { /* sym, or no init form */ + if (atom(spec)) { val rest_syms = get_opt_param_syms(cdr(params)); - if (bindable(form)) - return cons(form, rest_syms); - if (bindable(car(form))) - return cons(car(form), rest_syms); + if (bindable(spec)) + return cons(spec, rest_syms); return rest_syms; - } else { /* has initform */ - val sym = car(form); - return cons(sym, get_opt_param_syms(cdr(params))); + } else { + val pat = car(spec); + return nappend2(get_param_syms(pat), get_opt_param_syms(cdr(params))); } } } -- cgit v1.2.3