From 64840c6e9099a67f3ce8a7d60e570eb6ab8fadae Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 11 Dec 2016 07:23:01 -0800 Subject: Method lookup doesn't throw on nonexistent slots. * eval.c (lookup_fun): When looking up (meth ...) syntax, avoid calling static_slot with a slot argument which isn't a static slot of the given type, otherwise an exception is thrown. The situation is turned instead into a nil return which just indicates "no binding". This allows, for instance, (fboundp '(meth foo bar)) to be safe. It makes no sense for that to return nil if foo doesn't name a struct type, but to throw an error if bar isn't a static slot in foo. --- eval.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eval.c b/eval.c index 5b7065e4..f3b94211 100644 --- a/eval.c +++ b/eval.c @@ -442,7 +442,8 @@ val lookup_fun(val env, val sym) val type = or2(find_struct_type(strct), if2(lisplib_try_load(strct), find_struct_type(strct))); - return if2(type, cons(sym, static_slot(type, slot))); + return if2(and2(type, static_slot_p(type, slot)), + cons(sym, static_slot(type, slot))); } else if (car(sym) == macro_s) { return lookup_mac(nil, cadr(sym)); } -- cgit v1.2.3