all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Glenn Morris <rgm@gnu.org>
Cc: Juanma Barranquero <lekktu@gmail.com>, 14831-done@debbugs.gnu.org
Subject: bug#14831: cl-member warnings during bootstrap
Date: Mon, 22 Jul 2013 16:40:27 -0400	[thread overview]
Message-ID: <jwvy58ywnbw.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <wgvc4abf8n.fsf@fencepost.gnu.org> (Glenn Morris's message of "Tue, 16 Jul 2013 13:12:56 -0400")

>> 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






      reply	other threads:[~2013-07-22 20:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-09 14:42 bug#14831: cl-member warnings during bootstrap Juanma Barranquero
2013-07-09 15:54 ` Glenn Morris
2013-07-09 15:56   ` Juanma Barranquero
2013-07-15 11:36   ` Juanma Barranquero
2013-07-15 16:10     ` Glenn Morris
2013-07-15 16:23       ` Juanma Barranquero
2013-07-15 19:48         ` Glenn Morris
2013-07-15 19:50           ` Juanma Barranquero
2013-07-16  0:19           ` Stefan Monnier
2013-07-16  1:37             ` Glenn Morris
2013-07-16  8:57               ` Stefan Monnier
2013-07-16 17:12                 ` Glenn Morris
2013-07-22 20:40                   ` Stefan Monnier [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvy58ywnbw.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=14831-done@debbugs.gnu.org \
    --cc=lekktu@gmail.com \
    --cc=rgm@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.