Subject: 23.1.50; defun* generates incorrect code for handling arglist keyword lookup
From: Miles Bader <[email-masked]>
To: [email-masked]
Date: Mon, 22 Jun 2009 15:45:29 +0900

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:

Given the following code:

   (require 'cl)
   (defun* oink (&key a b) (list a b))

then evaluating:

   (oink :b :a :a 42)
   => (:a :a)

... which is incorrect.  The correct answer is (42 :A).

Looking at the macro-expansion of the above defun* form, the reason is
obvious:  the generated code uses (car (cdr (memq KEYWORD ARGLIST))) to
look up keyword argument values, which is obviously bogus if a preceding
argument value is the same as a keyword.  It would be more correct to
use (plist-get ARGUMENT KEYWORD), and that's what common-lisp systems I
tested return for this test.

However, the code in cl.el that generates keyword handling code is so
confusing, I'm not really sure how to fix this; presumably something in
`cl-do-arglist'?

Thanks,

-Miles

If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
    `bt full' and `xbacktrace'.
If you would like to further debug the crash, please read the file
/usr/local/share/emacs/23.1.50/etc/DEBUG for instructions.

In GNU Emacs 23.1.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.16.2)
 of 2009-06-22 on dhlpc061
Windowing system distributor `The X.Org Foundation', version 11.0.10601901
Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: ja_JP.UTF-8
  value of $XMODIFIERS: @im=SCIM
  locale-coding-system: utf-8-unix
  default-enable-multibyte-characters: t

Major mode: Lisp Interaction

Minor modes in effect:
  shell-dirtrack-mode: t
  diff-auto-refine-mode: t
  show-paren-mode: t
  recentf-mode: t
  rcirc-track-minor-mode: t
  minibuffer-electric-default-mode: t
  display-time-mode: t
  desktop-save-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  global-auto-composition-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  temp-buffer-resize-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
C-p C-n C-u C-p C-u C-p n i n n n n n n n n n n n n 
n n SPC n n n n n c y M-v C-u C-u C-p C-u C-p C-u C-p 
C-u C-p C-u C-p C-u C-p C-n C-n C-n C-n C-n C-n C-n 
= C-e C-a C-x C-v C-g C-g C-g C-x C-v $ % <backspace> 
e <backspace> l s e / m a s t e r / l i s p / e m a 
c s - l <tab> i <tab> e m <tab> <backspace> <backspace> 
c l - m a <tab> <return> C-s C-s m e C-a C-s m e m 
q C-s C-s C-s C-s C-s C-s C-s C-a C-s k e y w o C-s 
C-a C-s m e m q C-s C-s C-s C-s C-s C-s C-M-u C-M-u 
C-M-u C-M-a C-s ( c d r SPC ( C-s C-s C-s C-s C-s C-s 
C-s C-s C-s C-s C-a C-s k e y w o r d C-s C-s C-s C-s 
C-s C-x 2 C-x b * s c SPC <return> ( <escape> > <return> 
( r e q u i r e SPC ' c l ) C-j C-y <backspace> C-a 
C-M-f C-a M-f * C-e C-j <help-echo> <down-mouse-2> 
<mouse-2> C-p C-e C-j C-x n C-a C-z C-z C-z C-z C-z 
C-z C-z C-z C-z C-z C-z C-z C-z C-z C-z C-n C-n C-n 
C-n C-n C-n C-n C-n C-n C-n C-e C-b C-b C-b C-b C-a 
C-s ' e <backspace> m e m C-a C-v C-s C-s C-s C-s C-s 
C-s C-s C-s C-s C-s C-s C-s C-a C-s l o o k C-s C-s 
C-a C-x 1 C-x b <return> <escape> x r e p o r t - e 
m SPC <return>

Recent messages:
Quit
x*DING*  [2 times]
Mark saved where search started [3 times]
Mark set
x*DING* 
Mark saved where search started [2 times]
Mark set [3 times]
Mark saved where search started
x*DING* 
Mark saved where search started [2 times]

-- 
Pray, v. To ask that the laws of the universe be annulled in behalf of a
single petitioner confessedly unworthy.