From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#68938: Emacs "master". Incorrect code generated by pcase. Date: Mon, 5 Feb 2024 17:18:40 +0000 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22465"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier To: 68938@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Feb 05 18:20:07 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rX2db-0005co-CN for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 05 Feb 2024 18:20:07 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rX2dM-0006hE-LF; Mon, 05 Feb 2024 12:19:52 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rX2dK-0006gw-Ft for bug-gnu-emacs@gnu.org; Mon, 05 Feb 2024 12:19:50 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rX2dK-0004vl-5M for bug-gnu-emacs@gnu.org; Mon, 05 Feb 2024 12:19:50 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rX2dV-0008R6-S4; Mon, 05 Feb 2024 12:20:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: monnier@iro.umontreal.ca, bug-gnu-emacs@gnu.org Resent-Date: Mon, 05 Feb 2024 17:20:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 68938 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: Stefan Monnier Original-Received: via spool by submit@debbugs.gnu.org id=B.170715356232368 (code B ref -1); Mon, 05 Feb 2024 17:20:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 5 Feb 2024 17:19:22 +0000 Original-Received: from localhost ([127.0.0.1]:52218 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rX2cs-0008Q0-CM for submit@debbugs.gnu.org; Mon, 05 Feb 2024 12:19:22 -0500 Original-Received: from lists.gnu.org ([2001:470:142::17]:32904) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rX2cr-0008Pm-AV for submit@debbugs.gnu.org; Mon, 05 Feb 2024 12:19:21 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rX2cZ-0006RO-Cf for bug-gnu-emacs@gnu.org; Mon, 05 Feb 2024 12:19:03 -0500 Original-Received: from mail.muc.de ([193.149.48.3]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rX2cR-0004i2-A3 for bug-gnu-emacs@gnu.org; Mon, 05 Feb 2024 12:19:03 -0500 Original-Received: (qmail 26334 invoked by uid 3782); 5 Feb 2024 18:18:40 +0100 Original-Received: from acm.muc.de (pd953a84b.dip0.t-ipconnect.de [217.83.168.75]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Mon, 05 Feb 2024 18:18:40 +0100 Original-Received: (qmail 8422 invoked by uid 1000); 5 Feb 2024 17:18:40 -0000 Content-Disposition: inline X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.3; envelope-from=acm@muc.de; helo=mail.muc.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:279458 Archived-At: 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).