unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Robert Irelan <rirelan@gmail.com>
To: Phil Sainty <psainty@orcon.net.nz>
Cc: "Basil L. Contovounesios" <contovob@tcd.ie>,
	Lars Ingebrigtsen <larsi@gnus.org>,
	46958@debbugs.gnu.org
Subject: bug#46958: 28.0.50; invalid-function error for macros that have function bindings
Date: Sun, 7 Mar 2021 23:18:15 -0800	[thread overview]
Message-ID: <CAJUyYjo4DF-toBadm-745b660hMSJTsSsjkbn4F-js6Xb24GNw@mail.gmail.com> (raw)
In-Reply-To: <2406e008-05f0-f95f-cc95-72f873bc12b8@orcon.net.nz>

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 <psainty@orcon.net.nz> 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





  reply	other threads:[~2021-03-08  7:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-06  2:00 bug#46958: 28.0.50; invalid-function error for macros that have function bindings Robert Irelan
2021-03-06 12:55 ` Lars Ingebrigtsen
2021-03-06 14:24   ` Basil L. Contovounesios
2021-03-06 18:28     ` Robert Irelan
2021-03-06 22:39       ` Phil Sainty
2021-03-07 14:27         ` Basil L. Contovounesios
2021-03-07 21:38         ` Robert Irelan
2021-03-08  6:30           ` Phil Sainty
2021-03-08  7:18             ` Robert Irelan [this message]
2021-03-08  9:06               ` Phil Sainty
2022-06-20  1:10               ` Lars Ingebrigtsen
2021-03-07 14:33   ` Pip Cet
2021-03-07 15:58     ` Lars Ingebrigtsen
2021-03-07 18:06       ` Pip Cet

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=CAJUyYjo4DF-toBadm-745b660hMSJTsSsjkbn4F-js6Xb24GNw@mail.gmail.com \
    --to=rirelan@gmail.com \
    --cc=46958@debbugs.gnu.org \
    --cc=contovob@tcd.ie \
    --cc=larsi@gnus.org \
    --cc=psainty@orcon.net.nz \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).