all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: 68938@debbugs.gnu.org
Cc: Stefan Monnier <monnier@iro.umontreal.ca>
Subject: bug#68938: Emacs "master".  Incorrect code generated by pcase.
Date: Mon, 5 Feb 2024 17:18:40 +0000	[thread overview]
Message-ID: <ZcEYcPYEMGd_GR4p@ACM> (raw)

Hello Stefan and Emacs.

In a development version of Emacs, last synched with master in December,
I have added the following pcase clause to macroexp--expand-all in
lisp/emacs-lisp/macroexp.el:

            (`(,(and 'defalias d
                     (guard (and (null defining-symbol)
                                 (symbol-with-pos-p d))))
               ',sym . ,_)
             ;; Here, don't change the form; just set `defining-symbol'
             ;; for a (defalias 'foo ...) in the source code.
             ;; (when (symbol-with-pos-p d)
             (setq defining-symbol sym)
             form)

..  pcase expands that clause to this cond clause:

((eq x0 'defalias)
 (cond
  ((let* ((d x0))
     (and (null defining-symbol) (symbol-with-pos-p d)))
   (let* ((x14 (cdr-safe form)))
     (cond
      ((consp x14)
       (let* ((x15 (car-safe x14)))
         (cond
          ((consp x15)
           (let* ((x16 (car-safe x15)))
             (cond
              ((eq x16 'quote)
               (let* ((x17 (cdr-safe x15)))
                 (cond
                  ((consp x17)
                   (let* ((x18 (car-safe x17)) (x19 (cdr-safe x17)))
                     (cond
                      ((null x19)
                       (let ((d x0) (sym x18))
                         (ignore d) (setq defining-symbol sym) form))
                      ((consp x0)
                       (let* ((x21 (car-safe x0)))
                         (if (eq x21 'lambda) (funcall pcase-3 x0 x14)
                           (funcall pcase-2 x0))))
                      (t (funcall pcase-2 x0)))))
                  ((consp x0)
                   (let* ((x23 (car-safe x0)))
                     (if (eq x23 'lambda) (funcall pcase-3 x0 x14)
                       (funcall pcase-2 x0))))
                  (t (funcall pcase-2 x0)))))
              ((consp x0)
               (let* ((x25 (car-safe x0)))
                 (if (eq x25 'lambda) (funcall pcase-3 x0 x14)
                   (funcall pcase-2 x0))))
              (t (funcall pcase-2 x0)))))
          ((consp x0)
           (let* ((x27 (car-safe x0)))
             (if (eq x27 'lambda) (funcall pcase-3 x0 x14)
               (funcall pcase-2 x0))))
          (t (funcall pcase-2 x0)))))
      ((consp x0)
       (let* ((x29 (car-safe x0)))
         (if (eq x29 'lambda) (funcall pcase-3 x0 x14) (funcall pcase-2 x0))))
      (t (funcall pcase-2 x0)))))
  ((consp x0)
   (let* ((x31 (car-safe x0)))
     (if (eq x31 'lambda)
         (let* ((x33 (cdr-safe form))) (funcall pcase-3 x0 x33))
       (funcall pcase-2 x0))))
  (t (funcall pcase-2 x0))))

..  This contains errors:

(i) Although it has been established that x0 is 'defalias, there are many
  tests (consp x0).
(ii) There are calls of the form (funcall pcase-2 x0), i.e. (funcall
  pcase-2 'defalias).  This causes a wrong-number-of-arguments error.
(iii) There is no sign of the final `form' being returned, though this
  may be being done elsewhere.

-- 
Alan Mackenzie (Nuremberg, Germany).





             reply	other threads:[~2024-02-05 17:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-05 17:18 Alan Mackenzie [this message]
2024-02-05 18:27 ` bug#68938: Emacs "master". Incorrect code generated by pcase Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-06 12:58   ` Alan Mackenzie

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=ZcEYcPYEMGd_GR4p@ACM \
    --to=acm@muc.de \
    --cc=68938@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.