Subject: Re: bug#59900: 30.0.50; map pattern in pcase causes a byte-compile error

From: Akira Komamura <[email-masked]>
Date: Fri, 9 Dec 2022 16:58:28 +0900

On Fri, Dec 9, 2022 at 4:12 PM Eli Zaretskii <[email-masked]> wrote:

> Thanks, but all this still doesn't answer my questions,
> unfortunately.  You-all are describing something that I cannot wrap my
> head around, because that basic question was not answered yet.
>
> Would someone please take me through the problem step by step?
>

There is a MELPA package depending on `pcase'. It contains a `map' pattern:

(pcase-let* ((`(,_name . ,(map filename outline-path id
front-context-string indirectp))
  ...)

The support for `map' pattern is not built into `pcase.el'. Instead, it is
enabled through `pcase--get-macroexpander', which is implemented as follows:

(defun pcase--get-macroexpander (s)
  "Return the macroexpander for pcase pattern head S, or nil."
  (get s 'pcase-macroexpander))

It returns `pcase-macroexpander' property of the symbol (i.e. `map' in this
case). The property should be available at compile time. If not, the library
will fail to byte-compile.

To set the property of an additional pattern, `rx', `map', `seq', etc. all
use
`pcase-defmacro'. I think autoloading the `pcase-defmacro' form in `map.el'
can
prevent the error as well as possible future errors in other libraries.
This is
already done in `rx.el'.