From bccfc1f08dab5b2224ee3db191b06a18e0bea24d Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Mon, 24 Mar 2014 15:30:44 +0900 Subject: [PATCH] throw error when macro definition evaluates to non-procedure object --- src/macro.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/macro.c b/src/macro.c index 6142570f..e6f5db1d 100644 --- a/src/macro.c +++ b/src/macro.c @@ -288,7 +288,10 @@ macroexpand(pic_state *pic, pic_value expr, struct pic_senv *senv) } pic_catch { pic_errorf(pic, "macroexpand error: %s", pic_errmsg(pic)); } - assert(pic_proc_p(v)); + + if (! pic_proc_p(v)) { + pic_errorf(pic, "macro definition \"~s\" evaluates to non-procedure object", var); + } mac = macro_new(pic, pic_proc_ptr(v), senv); xh_put_int(pic->macros, uniq, (long)mac); @@ -331,7 +334,10 @@ macroexpand(pic_state *pic, pic_value expr, struct pic_senv *senv) } pic_catch { pic_errorf(pic, "macroexpand error: %s", pic_errmsg(pic)); } - assert(pic_proc_p(v)); + + if (! pic_proc_p(v)) { + pic_errorf(pic, "macro definition \"~s\" evaluates to non-procedure object", var); + } mac = macro_new(pic, pic_proc_ptr(v), NULL); xh_put_int(pic->macros, uniq, (long)mac);