emacs-cl icon indicating copy to clipboard operation
emacs-cl copied to clipboard

Emacs `cl:lambda` macro handles &KEY arguments incorrectly.

Open j3pic opened this issue 3 years ago • 0 comments

In Common Lisp, if you write something like this and then don't use the keyword arguments, then the variables should be bound to NIL:

(cl:defun MAKE-PACKAGE (name &KEY NICKNAMES USE)
  (let ((package (make-vector 8 'PACKAGE))
        (use-packages (mapcar #'FIND-PACKAGE USE)))
    (aset package 1 (STRING name))                      ;name                                                                                            

Instead, cl:lambda initializes the NICKNAMES and USE variables to unbound, which results in a type error when (mapcar #'FIND-PACKAGE USE) is evaluated.

As a result of that, I can't load load-cl.el in Emacs 26.1. It looks like some post-processing is supposed to happen to transform unbound to nil, but for some reason the unbound value makes it through.

It looks like something is going wrong when parsing the lambda list. I couldn't understand what the code generated by the keyword-assignments macro is supposed to do, but functions like lambda-list-keys and lambda-list-keyword-defaults seem to return the correct values.

j3pic avatar Apr 25 '22 06:04 j3pic