GNU bug report logs - #25965
26.0.50; iter-lambda may evaluate certain forms twice

Previous Next

Package: emacs;

Reported by: Andreas Politz <politza <at> hochschule-trier.de>

Date: Sat, 4 Mar 2017 08:04:01 UTC

Severity: normal

Tags: patch

Found in version 26.0.50

Done: Gemini Lasswell <gazally <at> runbox.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Gemini Lasswell <gazally <at> runbox.com>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#25965: closed (26.0.50; iter-lambda may evaluate certain
 forms twice )
Date: Thu, 05 Oct 2017 19:53:01 +0000
[Message part 1 (text/plain, inline)]
Your message dated Thu, 05 Oct 2017 12:51:55 -0700
with message-id <87h8vd5q5g.fsf <at> runbox.com>
and subject line Re: bug#25965: 26.0.50; iter-lambda may evaluate certain forms twice
has caused the debbugs.gnu.org bug report #25965,
regarding 26.0.50; iter-lambda may evaluate certain forms twice 
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
25965: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=25965
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Andreas Politz <politza <at> hochschule-trier.de>
To: bug-gnu-emacs <at> gnu.org
Subject: 26.0.50; iter-lambda may evaluate certain forms twice 
Date: Sat, 04 Mar 2017 09:02:32 +0100
Here is an example where the behavior occurs.

#+BEGIN_SRC emacs-lisp
  ;; -*- lexical-binding: t -*-
  (iter-next
   (funcall (iter-lambda ()
              (let* ((fill-column 10) ;;any special variable will do
                     (i 0)
                     (j (setq i (1+ i))))
                (iter-yield i)))))
  ;; => 2
#+END_SRC

But the result should be 1.  Looking at the expanded code, we see i
incremented indeed twice.

#+BEGIN_SRC emacs-lisp
  ;; ....
  (setq cps-state-atom--1522
        #'(lambda nil
            (setq cps-current-value--1513
                  (let
                      ((fill-column cps-binding-fill-column--1516))
                    (unwind-protect
                        (prog1
                            (setq cps-binding-i--1517
                                  (1+ cps-binding-i--1517))
                          (setq cps-current-state--1514 cps-state-let*--1521))
                      (setq cps-binding-fill-column--1516 fill-column))
                    (prog1
                        (setq cps-binding-i--1517
                              (1+ cps-binding-i--1517))
                      (setq cps-current-state--1514 cps-state-let*--1521))))))
  ;; ...
#+END_SRC

The unwind-protect form is created in this function.

#+BEGIN_SRC emacs-lisp
  (defun cps--make-dynamic-binding-wrapper (dynamic-var static-var)
    (cl-assert lexical-binding)
    (lambda (form)
      `(let ((,dynamic-var ,static-var))
         (unwind-protect ; Update the static shadow after evaluation is done
              ,form
           (setf ,static-var ,dynamic-var))
         ,form)))
#+END_SRC

And it seems to me that the second occurrence of ,form is just an
error.

By the way, why is debugging these generators made so difficult (via the
implementation of cps--gensym) ?

-ap


[Message part 3 (message/rfc822, inline)]
From: Gemini Lasswell <gazally <at> runbox.com>
To: Daniel Colascione <dancol <at> dancol.org>
Cc: 25965-done <at> debbugs.gnu.org, Stefan Monnier <monnier <at> IRO.UMontreal.CA>,
 Andreas Politz <politza <at> hochschule-trier.de>
Subject: Re: bug#25965: 26.0.50; iter-lambda may evaluate certain forms twice
Date: Thu, 05 Oct 2017 12:51:55 -0700
Pushed to emacs-26.


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

Previous Next


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