diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-12-11 07:23:01 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-12-11 07:23:01 -0800 |
commit | 6fbedee8d28ed964ef6b9eb8b01fd0911d99c9ff (patch) | |
tree | 6b3eb09a3665a123a66d3b24e607d6ae307acbc9 /eval.c | |
parent | 1ca65fef46ca68ca18e3db5a5eac316d5cf25799 (diff) | |
download | txr-6fbedee8d28ed964ef6b9eb8b01fd0911d99c9ff.tar.gz txr-6fbedee8d28ed964ef6b9eb8b01fd0911d99c9ff.tar.bz2 txr-6fbedee8d28ed964ef6b9eb8b01fd0911d99c9ff.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.
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -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)); } |