diff options
author | Keith Packard <keithp@keithp.com> | 2017-12-01 11:31:29 +0100 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2017-12-01 11:31:29 +0100 |
commit | 796017262cd433af5d143cc7168c944e1e05f4e2 (patch) | |
tree | 398e501702fbc209e17cc0f5e6085f25988f6841 /src/lisp | |
parent | cd0bd9791a77868c226d285bf4d57e8c321755d5 (diff) |
altos/lisp: Fix pairp builtin
Pairs are non-nil cons values; add an explicit check for nil here
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/lisp')
-rw-r--r-- | src/lisp/ao_lisp_builtin.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lisp/ao_lisp_builtin.c b/src/lisp/ao_lisp_builtin.c index 693cc3ca..f13f2180 100644 --- a/src/lisp/ao_lisp_builtin.c +++ b/src/lisp/ao_lisp_builtin.c @@ -675,7 +675,13 @@ ao_lisp_do_typep(int type, struct ao_lisp_cons *cons) ao_poly ao_lisp_do_pairp(struct ao_lisp_cons *cons) { - return ao_lisp_do_typep(AO_LISP_CONS, cons); + ao_poly v; + if (!ao_lisp_check_argc(_ao_lisp_atom_led, cons, 1, 1)) + return AO_LISP_NIL; + v = ao_lisp_arg(cons, 0); + if (v != AO_LISP_NIL && ao_lisp_poly_type(v) == AO_LISP_CONS) + return _ao_lisp_bool_true; + return _ao_lisp_bool_false; } ao_poly |