throw error when macro definition evaluates to non-procedure object

This commit is contained in:
Yuichi Nishiwaki 2014-03-24 15:30:44 +09:00
parent b61da9bc47
commit bccfc1f08d
1 changed files with 8 additions and 2 deletions

View File

@ -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);