Subject: bug#14831: closed (Re: bug#14831: cl-member warnings during bootstrap)

From: [email-masked] (GNU bug Tracking System)
Date: Mon, 22 Jul 2013 20:41:05 +0000

Your bug report

#14831: cl-member warnings during bootstrap

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
14831: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=14831
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#14831: cl-member warnings during bootstrap
From: Stefan Monnier <[email-masked]>
To: Glenn Morris <[email-masked]>
Cc: Juanma Barranquero <[email-masked]>, [email-masked]
Date: Mon, 22 Jul 2013 16:40:27 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

>> Aha!  So it's the compiler-macro of add-to-list which turns an
>> add-to-list call into a cl-pushnew call, which is then macro-expanded to
>> something that uses cl-member, which should be turned into a plain
>> `member' by `cl--compiler-macro-member'.  So it can be fixed by changing
>> the compiler-macro of add-to-list not to use cl-pushnew.

I installed the patch below which tightens things up a bit.

        Stefan

=== modified file 'lisp/subr.el'
--- lisp/subr.el	2013-07-19 12:18:16 +0000
+++ lisp/subr.el	2013-07-22 16:46:55 +0000
@@ -1498,9 +1498,10 @@
       ;; FIXME: Something like this could be used for `set' as well.
       (if (or (not (eq 'quote (car-safe list-var)))
               (special-variable-p (cadr list-var))
-              (and append compare-fn))
+              (not (macroexp-const-p append)))
           exp
         (let* ((sym (cadr list-var))
+               (append (eval append))
                (msg (format "`add-to-list' can't use lexical var `%s'; use `push' or `cl-pushnew'"
                             sym))
                ;; Big ugly hack so we only output a warning during
@@ -1513,13 +1514,17 @@
                           (when (assq sym byte-compile--lexical-environment)
                             (byte-compile-log-warning msg t :error))))
                (code
-                (if append
                     (macroexp-let2 macroexp-copyable-p x element
-                    `(unless (member ,x ,sym)
-                       (setq ,sym (append ,sym (list ,x)))))
+                  `(unless ,(if compare-fn
+                                (progn
                   (require 'cl-lib)
-                  `(cl-pushnew ,element ,sym
-                               :test ,(or compare-fn '#'equal)))))
+                                  `(cl-member ,x ,sym :test ,compare-fn))
+                              ;; For bootstrapping reasons, don't rely on
+                              ;; cl--compiler-macro-member for the base case.
+                              `(member ,x ,sym))
+                     ,(if append
+                          `(setq ,sym (append ,sym (list ,x)))
+                        `(push ,x ,sym))))))
           (if (not (macroexp--compiling-p))
               code
             `(progn

Subject: cl-member warnings during bootstrap
From: Juanma Barranquero <[email-masked]>
To: Bug-Gnu-Emacs <[email-masked]>
Date: Tue, 9 Jul 2013 16:42:03 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Package: emacs
Version: 24.3.50

During bootstrap, there are two cl-member related warnings:

In end of data:
international/mule-cmds.el:2981:1:Warning: the function `cl-member' is not
    known to be defined.

In end of data:
replace.el:2338:1:Warning: the function `cl-member' is not known to be
    defined.

and indeed, mule-cmds.elc and replace.elc contain references to
cl-member. Recompiling these files after bootstrap removes these
references.