Subject: Re: bug#41381: 28.0.50; Can't compile file containing a local pcase macro

From: Pip Cet <[email-masked]>
Date: Wed, 03 Jun 2020 21:59:36 +0000

Philipp Stephani <[email-masked]> writes:
> $ cat test.el
> ;;; -*- lexical-binding: t; -*-
> (pcase-defmacro test () '_)
> (defun test () (pcase nil ((test))))
>
> $ emacs -Q -batch -l bytecomp -f batch-byte-compile test.el
>
> In toplevel form:
> test.el:3:1: Error: Symbol’s function definition is void: test--pcase-macroexpander
>
> It works if the pcase macro is surrounded with `eval-when-compile', but
> that shouldn't be necessary I think.

Wouldn't it be better to surround the pcase-defmacro call with
(eval-and-compile ...)?

I think it would be great if there were some clever way to make eager
macro expansion less eager, so things like evaluating the following two
expressions one after another

(defmacro foo () 3)

(progn
  (defmacro foo () 4)
  (foo))

would produce the right result (4 rather than 3). That would solve this
problem as well, but it's probably impossible to do with reasonable
performance.