From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#41618: 28.0.50; Can't byte-compile an edebugged macro Date: 31 May 2020 17:01:19 -0000 Organization: muc.de e.V. Message-ID: <20200531170119.11733.qmail@mail.muc.de> References: Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="31941"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: tin/2.4.4-20191224 ("Millburn") (FreeBSD/11.3-RELEASE-p9 (amd64)) Cc: 41618-done@debbugs.gnu.org To: Philipp Stephani Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 31 19:02:15 2020 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 1jfRLi-0008AU-IW for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 31 May 2020 19:02:14 +0200 Original-Received: from localhost ([::1]:43094 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jfRLh-0001z1-HK for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 31 May 2020 13:02:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58070) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jfRLX-0001wf-6G for bug-gnu-emacs@gnu.org; Sun, 31 May 2020 13:02:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50389) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jfRLW-0005eJ-QN for bug-gnu-emacs@gnu.org; Sun, 31 May 2020 13:02:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jfRLW-00027D-N6 for bug-gnu-emacs@gnu.org; Sun, 31 May 2020 13:02:02 -0400 Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Sun, 31 May 2020 17:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 41618 X-GNU-PR-Package: emacs Mail-Followup-To: 41618@debbugs.gnu.org, acm@muc.de, p.stephani2@gmail.com Original-Received: via spool by 41618-done@debbugs.gnu.org id=D41618.15909444848084 (code D ref 41618); Sun, 31 May 2020 17:02:02 +0000 Original-Received: (at 41618-done) by debbugs.gnu.org; 31 May 2020 17:01:24 +0000 Original-Received: from localhost ([127.0.0.1]:33700 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jfRKu-00026J-59 for submit@debbugs.gnu.org; Sun, 31 May 2020 13:01:24 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:55102 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1jfRKr-00026A-BS for 41618-done@debbugs.gnu.org; Sun, 31 May 2020 13:01:23 -0400 Original-Received: (qmail 11734 invoked by uid 3782); 31 May 2020 17:01:19 -0000 In-Reply-To: X-Newsgroups: gnu.emacs.bug 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" Xref: news.gmane.io gmane.emacs.bugs:181299 Archived-At: Hello, Philipp. In article you wrote: > 1. Define some arbitrary macro: > (defmacro foo ()) > 2. Edebug it using C-u C-M-x. This was not actually relevant. A simple evaluation with C-M-x produces the same error. > 3. Attempt to byte-compile it using M-: (byte-compile 'foo). > This produces an error: > Wrong type argument: listp, #[0 "\300\207" [nil] 1] > The stack trace is > Debugger entered--Lisp error: (wrong-type-argument listp #f(compiled-function () #)) > eval((macro . #f(compiled-function () #)) t) > #f(compiled-function (form) #)(foo) > byte-compile(foo) > eval((byte-compile 'foo) t) > eval-expression((byte-compile 'foo) nil nil 127) > funcall-interactively(eval-expression (byte-compile 'foo) nil nil 127) > call-interactively(eval-expression nil nil) > command-execute(eval-expression) This was quite a simple bug. At the end of byte-compile, the code does two things: (i) If the argument to byte-compile is a symbol, the result is eval'd. (ii) If a macro is being compiled, 'macro is pushed onto the result. When both of these things were necessary, they were being done in the wrong order, throwing the error. I've committed a fix to the emacs-27 branch, and it should reach master the next time "somebody" copies the commits over. In the mean time, here's that patch, should you want to apply it to your system now: diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 72dbfd74b1..22e648e44b 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -2755,14 +2755,15 @@ byte-compile ;; Expand macros. (setq fun (byte-compile-preprocess fun)) (setq fun (byte-compile-top-level fun nil 'eval)) - (if macro (push 'macro fun)) (if (symbolp form) ;; byte-compile-top-level returns an *expression* equivalent to the ;; `fun' expression, so we need to evaluate it, tho normally ;; this is not needed because the expression is just a constant ;; byte-code object, which is self-evaluating. - (fset form (eval fun t)) - fun))))))) + (setq fun (eval fun t))) + (if macro (push 'macro fun)) + (if (symbolp form) (fset form fun)) + fun)))))) (defun byte-compile-sexp (sexp) "Compile and return SEXP." > In GNU Emacs 28.0.50 (build 19, x86_64-pc-linux-gnu, GTK+ Version 3.24.14, cairo version 1.16.0) > of 2020-05-30 > Repository revision: 3dbe6530b124436550dae4db6cd4b7b380e95377 > Repository branch: master > Windowing system distributor 'The X.Org Foundation', version 11.0.12007000 > System Description: Debian GNU/Linux rodete [ .... ] -- Alan Mackenzie (Nuremberg, Germany).