summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-12-11 07:23:01 -0800
committerKaz Kylheku <kaz@kylheku.com>2016-12-11 07:23:01 -0800
commit64840c6e9099a67f3ce8a7d60e570eb6ab8fadae (patch)
tree6b3eb09a3665a123a66d3b24e607d6ae307acbc9
parentc29faded418347c9765182357c9402744bc5b7ae (diff)
downloadtxr-64840c6e9099a67f3ce8a7d60e570eb6ab8fadae.tar.gz
txr-64840c6e9099a67f3ce8a7d60e570eb6ab8fadae.tar.bz2
txr-64840c6e9099a67f3ce8a7d60e570eb6ab8fadae.zip
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.
-rw-r--r--eval.c3
1 files changed, 2 insertions, 1 deletions
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));
}