Subject: Re: bug#42691: 28.0.50; eval-and-compile

From: Helmut Eller <[email-masked]>
Date: Mon, 03 Aug 2020 12:27:15 +0200

On Mon, Aug 03 2020, Andreas Schwab wrote:

> On Aug 03 2020, Helmut Eller wrote:
>
>> Compiling this example:
>>
>>   (require 'cl-lib)
>>   (cl-macrolet ((foo () '123))
>>     (eval-and-compile (foo)))
>>
>> with
>>
>>   emacs -Q --batch -f batch-byte-compile bug.el
>>
>> prints:
>>
>>   In toplevel form:
>>   bug.el:2:1: Error: Symbol’s function definition is void: foo
>>
>> I think when compiling eval-and-compile the macro-environment is not
>> passed along properly.
>
> Only the body of eval-and-compile is evaluated at that point.  If you
> want to modify the environment of the evaluation, you need to move that
> modification inside the eval-and-compile form.

Are you saying this is not a bug in eval-and-compile?

The docstring of eval-and-compile says eval-and-compile is like progn,
except that the body it is evaluated at compile-time too.  If it is
supposed to work like progn, then the environment should be defined as
for progn.

Helmut