GNU bug report logs - #28990
27.0.50; thunk-delay: running expansion also requires lexical-binding

Previous Next

Package: emacs;

Reported by: Michael Heerdegen <michael_heerdegen <at> web.de>

Date: Wed, 25 Oct 2017 13:49:02 UTC

Severity: minor

Found in version 27.0.50

Done: Michael Heerdegen <michael_heerdegen <at> web.de>

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 28990 in the body.
You can then email your comments to 28990 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#28990; Package emacs. (Wed, 25 Oct 2017 13:49:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Michael Heerdegen <michael_heerdegen <at> web.de>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 25 Oct 2017 13:49:02 GMT) Full text and rfc822 format available.

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

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: bug-gnu-emacs <at> gnu.org
Cc: Nicolas Petton <nicolas <at> petton.fr>
Subject: 27.0.50; thunk-delay: running expansion also requires lexical-binding
Date: Wed, 25 Oct 2017 15:47:45 +0200
Hello,

having only lexical-binding: t in "thunk.el"'s header is not sufficient:
to make thunks work ok, `thunk-delay' needs lexical-binding when the
expansion is run.

Try e.g. something trivial as

#+begin_src emacs-lisp
(defun my-thunk-test ()
  (thunk-force (thunk-delay (+ 1 2))))
#+end_src

This compiles ok, but executing (my-thunk-test) without lexbind enabled
gives you a meaningless error like "void-variable: forced".

I think we should document (in the file header) that lexical-binding
mode is required when thunks are created with `thunk-delay'.  I think we
could additionally raise an error in the expansion of `thunk-delay' when
lexical-binding -> nil.


TIA,

Michael.




In GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.24)
 of 2017-10-25 built on drachen
Repository revision: cb73c70180f57f3fb99fae3aaefbacf0a61cea3f
Windowing system distributor 'The X.Org Foundation', version 11.0.11905000
System Description:	Debian GNU/Linux testing (buster)





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28990; Package emacs. (Fri, 27 Oct 2017 14:09:02 GMT) Full text and rfc822 format available.

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

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: 28990 <at> debbugs.gnu.org
Cc: Nicolas Petton <nicolas <at> petton.fr>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#28990: 27.0.50;
 thunk-delay: running expansion also requires lexical-binding
Date: Fri, 27 Oct 2017 16:08:12 +0200
[Message part 1 (text/plain, inline)]
Michael Heerdegen <michael_heerdegen <at> web.de> writes:

> #+begin_src emacs-lisp
> (defun my-thunk-test ()
>   (thunk-force (thunk-delay (+ 1 2))))
> #+end_src
>
> This compiles ok, but executing (my-thunk-test) without lexbind enabled
> gives you a meaningless error like "void-variable: forced".

Nicolas, Stefan - ok to fix it like that?

[0001-WIP-Fix-bug-28990.patch (text/x-diff, inline)]
From 45fe6b1bc9573257e59842283fd7da36d760c524 Mon Sep 17 00:00:00 2001
From: Michael Heerdegen <michael_heerdegen <at> web.de>
Date: Thu, 26 Oct 2017 12:57:55 +0200
Subject: [PATCH] WIP: Fix bug#28990

---
 lisp/emacs-lisp/thunk.el | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lisp/emacs-lisp/thunk.el b/lisp/emacs-lisp/thunk.el
index bb6d277c27..6dc892c44b 100644
--- a/lisp/emacs-lisp/thunk.el
+++ b/lisp/emacs-lisp/thunk.el
@@ -44,9 +44,12 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'cl-macs))
+
 (defmacro thunk-delay (&rest body)
   "Delay the evaluation of BODY."
   (declare (debug t))
+  (cl-assert lexical-binding)
   (let ((forced (make-symbol "forced"))
         (val (make-symbol "val")))
     `(let (,forced ,val)
-- 
2.14.2

[Message part 3 (text/plain, inline)]
I would additionally add a sentence to "thunk.el"'s header saying that
creating thunks requires lexical binding.


TIA,

Michael.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28990; Package emacs. (Fri, 27 Oct 2017 16:02:02 GMT) Full text and rfc822 format available.

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

From: Nicolas Petton <nicolas <at> petton.fr>
To: Michael Heerdegen <michael_heerdegen <at> web.de>, 28990 <at> debbugs.gnu.org
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#28990: 27.0.50;
 thunk-delay: running expansion also requires lexical-binding
Date: Fri, 27 Oct 2017 18:01:28 +0200
[Message part 1 (text/plain, inline)]
Michael Heerdegen <michael_heerdegen <at> web.de> writes:

> Nicolas, Stefan - ok to fix it like that?

Yes, that's fine with me.

> I would additionally add a sentence to "thunk.el"'s header saying that
> creating thunks requires lexical binding.

That's a good idea, thanks.

Cheers,
Nico
[signature.asc (application/pgp-signature, inline)]

Reply sent to Michael Heerdegen <michael_heerdegen <at> web.de>:
You have taken responsibility. (Wed, 01 Nov 2017 14:10:02 GMT) Full text and rfc822 format available.

Notification sent to Michael Heerdegen <michael_heerdegen <at> web.de>:
bug acknowledged by developer. (Wed, 01 Nov 2017 14:10:02 GMT) Full text and rfc822 format available.

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

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Nicolas Petton <nicolas <at> petton.fr>
Cc: 28990-done <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#28990: 27.0.50;
 thunk-delay: running expansion also requires lexical-binding
Date: Wed, 01 Nov 2017 15:08:47 +0100
Nicolas Petton <nicolas <at> petton.fr> writes:

> > Nicolas, Stefan - ok to fix it like that?
>
> Yes, that's fine with me.
>
> > I would additionally add a sentence to "thunk.el"'s header saying that
> > creating thunks requires lexical binding.
>
> That's a good idea, thanks.

Done in bbb85eff49.

Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28990; Package emacs. (Wed, 01 Nov 2017 14:49:01 GMT) Full text and rfc822 format available.

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

From: Nicolas Petton <nicolas <at> petton.fr>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 28990-done <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#28990: 27.0.50;
 thunk-delay: running expansion also requires lexical-binding
Date: Wed, 01 Nov 2017 15:48:46 +0100
[Message part 1 (text/plain, inline)]
Michael Heerdegen <michael_heerdegen <at> web.de> writes:

> Done in bbb85eff49.

Great, thank you.

Cheers,
Nico
[signature.asc (application/pgp-signature, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 30 Nov 2017 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 7 years and 199 days ago.

Previous Next


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