unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#50738: `ert-deftest` bodies should not use lexical-binding=nil
@ 2021-09-22 11:13 Mattias Engdegård
  2021-09-22 14:26 ` Mattias Engdegård
  2021-09-22 20:33 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 5+ messages in thread
From: Mattias Engdegård @ 2021-09-22 11:13 UTC (permalink / raw)
  To: 50738

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?







^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#50738: `ert-deftest` bodies should not use lexical-binding=nil
  2021-09-22 11:13 bug#50738: `ert-deftest` bodies should not use lexical-binding=nil Mattias Engdegård
@ 2021-09-22 14:26 ` Mattias Engdegård
  2021-09-22 20:33 ` Lars Ingebrigtsen
  1 sibling, 0 replies; 5+ messages in thread
From: Mattias Engdegård @ 2021-09-22 14:26 UTC (permalink / raw)
  To: 50738

> 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.






^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#50738: `ert-deftest` bodies should not use lexical-binding=nil
  2021-09-22 11:13 bug#50738: `ert-deftest` bodies should not use lexical-binding=nil Mattias Engdegård
  2021-09-22 14:26 ` Mattias Engdegård
@ 2021-09-22 20:33 ` Lars Ingebrigtsen
  2021-09-23  5:50   ` Eli Zaretskii
  1 sibling, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2021-09-22 20:33 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: 50738

Mattias Engdegård <mattiase@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





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#50738: `ert-deftest` bodies should not use lexical-binding=nil
  2021-09-22 20:33 ` Lars Ingebrigtsen
@ 2021-09-23  5:50   ` Eli Zaretskii
  2021-09-25 18:33     ` Mattias Engdegård
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2021-09-23  5:50 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 50738, mattiase

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Date: Wed, 22 Sep 2021 22:33:48 +0200
> Cc: 50738@debbugs.gnu.org
> 
> Mattias Engdegård <mattiase@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, ...





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#50738: `ert-deftest` bodies should not use lexical-binding=nil
  2021-09-23  5:50   ` Eli Zaretskii
@ 2021-09-25 18:33     ` Mattias Engdegård
  0 siblings, 0 replies; 5+ messages in thread
From: Mattias Engdegård @ 2021-09-25 18:33 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 50738-done, Lars Ingebrigtsen

23 sep. 2021 kl. 07.50 skrev Eli Zaretskii <eliz@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.






^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-09-25 18:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-22 11:13 bug#50738: `ert-deftest` bodies should not use lexical-binding=nil Mattias Engdegård
2021-09-22 14:26 ` Mattias Engdegård
2021-09-22 20:33 ` Lars Ingebrigtsen
2021-09-23  5:50   ` Eli Zaretskii
2021-09-25 18:33     ` Mattias Engdegård

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).