GNU bug report logs - #50738
`ert-deftest` bodies should not use lexical-binding=nil

Previous Next

Package: emacs;

Reported by: Mattias Engdegård <mattiase <at> acm.org>

Date: Wed, 22 Sep 2021 11:15:02 UTC

Severity: normal

Done: Mattias Engdegård <mattiase <at> acm.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 50738 in the body.
You can then email your comments to 50738 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#50738; Package emacs. (Wed, 22 Sep 2021 11:15:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Mattias Engdegård <mattiase <at> acm.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 22 Sep 2021 11:15:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Mattias Engdegård <mattiase <at> acm.org>
To: bug-gnu-emacs <at> gnu.org
Subject: `ert-deftest` bodies should not use lexical-binding=nil
Date: Wed, 22 Sep 2021 13:13:58 +0200
Contrary to the expectations of everybody, the body of `ert-deftest` is always run with `lexical-binding` bound to nil regardless of what the file uses. This bug keeps causing trouble and it's high time we did something about it.

The technical reason for this snag is that the body is evaluated inside a `with-temp-buffer` clause (see `ert--run-test-internal`). Some options, ordered in roughly decreasing order of desirability (subjective):

1. Make with-temp-buffer use the current value of lexical-binding for the temporary buffer, instead of always using nil.
2. Make ert-deftest bodies use lexical-binding=t.
3. Make ert-deftest bodies use the file value of lexical-binding.

Although the last option looks sensible at first glance it's a bit messy in practice because of how ERT works (the value of lexical-binding needs to be threaded through various data structures) and shouldn't we migrate to lexical-binding anyway?






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50738; Package emacs. (Wed, 22 Sep 2021 14:27:02 GMT) Full text and rfc822 format available.

Message #8 received at 50738 <at> debbugs.gnu.org (full text, mbox):

From: Mattias Engdegård <mattiase <at> acm.org>
To: 50738 <at> debbugs.gnu.org
Subject: bug#50738: `ert-deftest` bodies should not use lexical-binding=nil
Date: Wed, 22 Sep 2021 16:26:46 +0200
> 1. Make with-temp-buffer use the current value of lexical-binding for the temporary buffer, instead of always using nil.

This causes three tests to fail, of which two just lazy test assumptions (fixed in 6ad77d36fd3f) and the third was the anonymous &rest case which is a real bug that was previously hidden.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50738; Package emacs. (Wed, 22 Sep 2021 20:35:01 GMT) Full text and rfc822 format available.

Message #11 received at 50738 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Mattias Engdegård <mattiase <at> acm.org>
Cc: 50738 <at> debbugs.gnu.org
Subject: Re: bug#50738: `ert-deftest` bodies should not use lexical-binding=nil
Date: Wed, 22 Sep 2021 22:33:48 +0200
Mattias Engdegård <mattiase <at> acm.org> writes:

> 1. Make with-temp-buffer use the current value of lexical-binding for
> the temporary buffer, instead of always using nil.

I think that makes the most sense?  

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50738; Package emacs. (Thu, 23 Sep 2021 05:51:01 GMT) Full text and rfc822 format available.

Message #14 received at 50738 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 50738 <at> debbugs.gnu.org, mattiase <at> acm.org
Subject: Re: bug#50738: `ert-deftest` bodies should not use lexical-binding=nil
Date: Thu, 23 Sep 2021 08:50:31 +0300
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Date: Wed, 22 Sep 2021 22:33:48 +0200
> Cc: 50738 <at> debbugs.gnu.org
> 
> Mattias Engdegård <mattiase <at> acm.org> writes:
> 
> > 1. Make with-temp-buffer use the current value of lexical-binding for
> > the temporary buffer, instead of always using nil.
> 
> I think that makes the most sense?  

I think it's dangerous to do this in Emacs 28.  After all, the
original issue is with ERT, whereas the change will affect gobs of
code.  After the emacs-28 branch is cut, if you feel adventurous, ...




Reply sent to Mattias Engdegård <mattiase <at> acm.org>:
You have taken responsibility. (Sat, 25 Sep 2021 18:34:03 GMT) Full text and rfc822 format available.

Notification sent to Mattias Engdegård <mattiase <at> acm.org>:
bug acknowledged by developer. (Sat, 25 Sep 2021 18:34:03 GMT) Full text and rfc822 format available.

Message #19 received at 50738-done <at> debbugs.gnu.org (full text, mbox):

From: Mattias Engdegård <mattiase <at> acm.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 50738-done <at> debbugs.gnu.org, Lars Ingebrigtsen <larsi <at> gnus.org>
Subject: Re: bug#50738: `ert-deftest` bodies should not use lexical-binding=nil
Date: Sat, 25 Sep 2021 20:33:49 +0200
23 sep. 2021 kl. 07.50 skrev Eli Zaretskii <eliz <at> gnu.org>:

> I think it's dangerous to do this in Emacs 28.  After all, the
> original issue is with ERT, whereas the change will affect gobs of
> code.  After the emacs-28 branch is cut, if you feel adventurous, ...

I agree, let's stick to fixing ERT now. Now done: in the most conservative way, using the ambient value of lexical-binding.





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 24 Oct 2021 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 157 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.