From c20ef52f6fed2400e078890b6e107a794026af99 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sun, 29 Apr 2018 16:17:07 +0200 Subject: [PATCH] mes: assq, assoc-ref: Handle non-A-LISTs. * src/mes.c (assq): Return #f if A-LIST is not a list. * module/mes/scm.mes (assoc): Likewise. --- module/mes/scm.mes | 2 +- src/mes.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/module/mes/scm.mes b/module/mes/scm.mes index 3aaac56d..9beac54b 100644 --- a/module/mes/scm.mes +++ b/module/mes/scm.mes @@ -109,7 +109,7 @@ (define assv-ref assq-ref) (define (assoc key alist) - (if (null? alist) #f + (if (not (pair? alist)) #f (if (equal? key (caar alist)) (car alist) (assoc key (cdr alist))))) diff --git a/src/mes.c b/src/mes.c index 46544f70..c0aae433 100644 --- a/src/mes.c +++ b/src/mes.c @@ -713,6 +713,8 @@ call (SCM fn, SCM x) SCM assq (SCM x, SCM a) { + if (TYPE (a) != TPAIR) + return cell_f; switch (TYPE (x)) { case TCHAR: