From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Robert Irelan Newsgroups: gmane.emacs.bugs Subject: bug#46958: 28.0.50; invalid-function error for macros that have function bindings Date: Sun, 7 Mar 2021 23:18:15 -0800 Message-ID: References: <87pn0co316.fsf@gnus.org> <87h7louzqp.fsf@tcd.ie> <2f63faf5-656a-e9cd-2249-0576da0b9e0c@orcon.net.nz> <2406e008-05f0-f95f-cc95-72f873bc12b8@orcon.net.nz> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35320"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "Basil L. Contovounesios" , Lars Ingebrigtsen , 46958@debbugs.gnu.org To: Phil Sainty Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Mar 08 08:19:09 2021 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 1lJAAX-00094O-0x for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 08 Mar 2021 08:19:09 +0100 Original-Received: from localhost ([::1]:36272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJAAW-0007iM-3x for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 08 Mar 2021 02:19:08 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57720) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJAAQ-0007i8-RZ for bug-gnu-emacs@gnu.org; Mon, 08 Mar 2021 02:19:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58636) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJAAQ-0004lt-KZ for bug-gnu-emacs@gnu.org; Mon, 08 Mar 2021 02:19:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lJAAQ-0007AL-Fe for bug-gnu-emacs@gnu.org; Mon, 08 Mar 2021 02:19:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Robert Irelan Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 08 Mar 2021 07:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46958 X-GNU-PR-Package: emacs Original-Received: via spool by 46958-submit@debbugs.gnu.org id=B46958.161518793327527 (code B ref 46958); Mon, 08 Mar 2021 07:19:02 +0000 Original-Received: (at 46958) by debbugs.gnu.org; 8 Mar 2021 07:18:53 +0000 Original-Received: from localhost ([127.0.0.1]:41949 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lJAAH-00079v-40 for submit@debbugs.gnu.org; Mon, 08 Mar 2021 02:18:53 -0500 Original-Received: from mail-wr1-f54.google.com ([209.85.221.54]:33075) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lJAAC-00079c-Iv for 46958@debbugs.gnu.org; Mon, 08 Mar 2021 02:18:51 -0500 Original-Received: by mail-wr1-f54.google.com with SMTP id 7so10310198wrz.0 for <46958@debbugs.gnu.org>; Sun, 07 Mar 2021 23:18:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=B01XU7xFmQx+Kr+VMtveCB8azL4AZ9VXLvYUqUmHZHo=; b=GeGi67dZsXc6aiV/OL61uNUUENaaya2UexS4ckA9VcgEt3rrR6dWnLdztAsZ4EW3HG Vv7x1hq/NlDZiR4sYWbCxoU5gIEUGCgP48GG7zN/IvJPxgXQT14bPATM6UCchCAPOArZ x0e8RikQx1Tu3zUpGKR1O+bsyPZke+m1A8usgbG0nQfO1SK3s/YnVAo8uGFf4TnjHsna d+SgPY9C1gOVXNOU6gpU1rDwPhCkmvorsPhUR7Q18krV64wccwgwwK7+xKFZYyr+wfhM JQWJW4zhbg8+sBN/AqxQ0DvmrU+39ixLKcJPXB1+v+55vVPJd4brifs+epcrBy+EYBCF Qlkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=B01XU7xFmQx+Kr+VMtveCB8azL4AZ9VXLvYUqUmHZHo=; b=Kf+2cmfvlv2fc8WdJnlaznw8OFunO0dJXoVpDkYUAfo+E9bEK7GtPqR24cinbHGtUZ 3ylo4EWPYmNo9H+f6KlZU6UvTQlHSDxEF9kQ+FAbWrJHa4E6f+OSqdz9b7vG1YOXQ0pQ NSENX3eSEPPUbclUJDoPXtvny7KvPxxbCmOmb/vT0shuiqvFnw4LNRUBfcXYpDMyTXHP YUEf1JeQBJwjHla33C6t0FQ5Ql2Z7EWSvCOMBlQD91F7wzK6FBn4HbRNbz/Il3F3R7j8 kaW262yaQbSFg+YHnGWhmILWZyYnkW8y09Xz/mPkLPEqaS6i8iApQW7v6KoLMvP5zTIV swSQ== X-Gm-Message-State: AOAM531lSgxK8BUdQyVEQuH5YvvAgTQ7AVgWu/tBNj3v3qOrCzBG88kr 1N8PCzhizw1RYYwnAHZrReB3xJCBmXlDVW5FcA== X-Google-Smtp-Source: ABdhPJz9tqKD7OFqPWTpt21kR7nyoPASLDhsrvLMTC1kudOAFPGZ6/3nWr0Y4UWIEzj9KxO/cO2RI8950bvbJcL9a3I= X-Received: by 2002:adf:ed87:: with SMTP id c7mr21454148wro.9.1615187922445; Sun, 07 Mar 2021 23:18:42 -0800 (PST) In-Reply-To: <2406e008-05f0-f95f-cc95-72f873bc12b8@orcon.net.nz> 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:201808 Archived-At: I extracted the macros into a separate library `org-fc-macs` and then called `(require 'org-fc-macs)` from the file where the error is occurring `org-fc-type-normal.el`. This seems to have fixed the issue. Now that I see that this has resolved the issue, I believe I can understand why. It looks the byte compiler can deal well if it is compiling a file where a function isn't defined by any of the `require` calls in the file - as long as the function is defined at runtime (which it would be with the way `org-fc` is written), you won't run into any issues. On the other hand, the byte compiler needs to have the definitions of all macros at hand during compile time, or else it won't be able to expand them correctly: https://www.gnu.org/software/emacs/manual/html_node/elisp/Compiling-Macros.html. In my case I'm using Doom Emacs, which uses the Straight package manager. Straight has switched to byte compiling each package (along with its explicit dependencies) in a separate process recently. When this happened, `org-fc-type-normal.el` could no longer see the macro definitions from `org-fc.el` at compile time, even though it could see them at run time. Here's an explanation from the Doom Emacs package maintainer: https://github.com/hlissner/doom-emacs/issues/4539#issuecomment-766307714. Therefore, it looks like this is not a new bug in Emacs. It would be nice if, when an invalid-function is thrown from bytecode, to check the runtime environment to see a macro with the same name is defined, and print a more informative error pointing out an issue with the compilation. On Sun, Mar 7, 2021 at 10:30 PM Phil Sainty wrote: > > On 8/03/21 10:38 am, Robert Irelan wrote: > > No, that results in a circular import. > > I think a traditional way of dealing with this is to move the > macro definitions to a separate library (e.g. fc-macs.el) and > each library which uses the macros can then (require 'fc-macs) > -- Robert Irelan rirelan@gmail.com