From 40aca13680f184f5ca48504a59a6e1c8f9066335 Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Mon, 19 Aug 2024 09:30:53 -0500 Subject: [PATCH] common-lisp: (list? nil) should be false (add test) In common-lisp, self-hosted test4 was failing and it appeared that nil and empty list () were being conflated. The root cause is that in common-lisp the form `(list? nil)` was returning true. Fix this in the core `list?` function. There was no test for this case so add one to step4 tests. --- impls/common-lisp/src/core.lisp | 2 +- impls/tests/step4_if_fn_do.mal | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/impls/common-lisp/src/core.lisp b/impls/common-lisp/src/core.lisp index 74d24fe5bd..283158f4fd 100644 --- a/impls/common-lisp/src/core.lisp +++ b/impls/common-lisp/src/core.lisp @@ -87,7 +87,7 @@ (make-mal-list values)) (defmal list? (value) - (wrap-boolean (or (mal-nil-p value) (mal-list-p value)))) + (wrap-boolean (mal-list-p value))) (defmal empty? (value) (wrap-boolean (zerop (length (mal-data-value value))))) diff --git a/impls/tests/step4_if_fn_do.mal b/impls/tests/step4_if_fn_do.mal index 46c1bb9247..4f19c8b71d 100644 --- a/impls/tests/step4_if_fn_do.mal +++ b/impls/tests/step4_if_fn_do.mal @@ -6,6 +6,8 @@ ;=>() (list? (list)) ;=>true +(list? nil) +;=>false (empty? (list)) ;=>true (empty? (list 1))