Skip to content

Commit

Permalink
common-lisp: (list? nil) should be false (add test)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kanaka committed Aug 19, 2024
1 parent b31180c commit 40aca13
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion impls/common-lisp/src/core.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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)))))
Expand Down
2 changes: 2 additions & 0 deletions impls/tests/step4_if_fn_do.mal
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
;=>()
(list? (list))
;=>true
(list? nil)
;=>false
(empty? (list))
;=>true
(empty? (list 1))
Expand Down

0 comments on commit 40aca13

Please sign in to comment.