Subject: bug#77278: 29.4; eval bug with lexical environment

From: Pip Cet <[email-masked]>
Date: Wed, 26 Mar 2025 12:38:47 +0000

"Daniel Cerqueira" <[email-masked]> writes:

> Eval this expression:
> (eval '(cons (quote a) x) '((x b)))
>
> It returns (a b) , it should return (a . b) .

The LEXENV argument to eval is an alist.  So

(eval '(cons (quote a) x) '((x . b)))

is what you want, and that does evaluate to (a . b).

> Also, eval this expression:
> (eval '(atom x) '((x b)))
>
> It returns nil , it should return t .

Same thing.  '((x b)) is equivalent to '((x . (b))), binding (b) to x,
so x is a list, not an atom.

> Since eval is the most important part of a LISP environment, it is good
> pratice to create a unit test to test eval, so that bugs in eval are
> easier to spot.

There are a few, it seems, in eval-tests.el.  However, if you'd like to
suggest more, that would be a good thing.

Pip