From unknown Sun Jun 22 00:20:53 2025 X-Loop: help-debbugs@gnu.org Subject: bug#25965: 26.0.50; iter-lambda may evaluate certain forms twice Resent-From: Andreas Politz Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 04 Mar 2017 08:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 25965 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 25965@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.148861458225245 (code B ref -1); Sat, 04 Mar 2017 08:04:01 +0000 Received: (at submit) by debbugs.gnu.org; 4 Mar 2017 08:03:02 +0000 Received: from localhost ([127.0.0.1]:39090 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ck4ec-0006Z6-GS for submit@debbugs.gnu.org; Sat, 04 Mar 2017 03:03:02 -0500 Received: from eggs.gnu.org ([208.118.235.92]:49809) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ck4eZ-0006Yb-6i for submit@debbugs.gnu.org; Sat, 04 Mar 2017 03:02:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ck4eT-0005Yj-AN for submit@debbugs.gnu.org; Sat, 04 Mar 2017 03:02:54 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:46455) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ck4eT-0005YZ-7p for submit@debbugs.gnu.org; Sat, 04 Mar 2017 03:02:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40777) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ck4eR-0006w5-Qg for bug-gnu-emacs@gnu.org; Sat, 04 Mar 2017 03:02:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ck4eO-0005Wz-O3 for bug-gnu-emacs@gnu.org; Sat, 04 Mar 2017 03:02:51 -0500 Received: from gateway-a.fh-trier.de ([143.93.54.181]:47764) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ck4eO-0005Wj-Cr for bug-gnu-emacs@gnu.org; Sat, 04 Mar 2017 03:02:48 -0500 X-Virus-Scanned: by Amavisd-new + McAfee uvscan + ClamAV [Rechenzentrum Hochschule Trier (RZ/HT)] Received: from localhost (ip5f5bdeea.dynamic.kabel-deutschland.de [95.91.222.234]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: politza) by gateway-a.fh-trier.de (Postfix) with ESMTPSA id 9496817972CD for ; Sat, 4 Mar 2017 09:02:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha1; c=simple/simple; d=hochschule-trier.de; s=default; t=1488614552; bh=b+gDDiSqmZC9DIpKoPH/ZyX10t4=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=OAAjVBkJlI+1NsJ16w09yrqDdnokIRGUbZfcL2rxXkgxngBek2zNiDTe+IVOVni1o 0p8okvTo5h55Eoh8APNhWh3ujUmcMZJiUBwndDUo2jfiqriz8d0iA2bV3oVsQoY3rz aQvB+UFWbqk9EXR0k6559+eQPoMsC/SLoCDhGElY= From: Andreas Politz Date: Sat, 04 Mar 2017 09:02:32 +0100 Message-ID: <87efydcvvr.fsf@luca> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) 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 From unknown Sun Jun 22 00:20:53 2025 X-Loop: help-debbugs@gnu.org Subject: bug#25965: 26.0.50; iter-lambda may evaluate certain forms twice Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 08 Mar 2017 21:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25965 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Andreas Politz , Daniel Colascione Cc: 25965@debbugs.gnu.org Received: via spool by 25965-submit@debbugs.gnu.org id=B25965.14890099502915 (code B ref 25965); Wed, 08 Mar 2017 21:53:01 +0000 Received: (at 25965) by debbugs.gnu.org; 8 Mar 2017 21:52:30 +0000 Received: from localhost ([127.0.0.1]:46789 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cljVV-0000kw-W7 for submit@debbugs.gnu.org; Wed, 08 Mar 2017 16:52:30 -0500 Received: from pruche.dit.umontreal.ca ([132.204.246.22]:52793) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cljVU-0000kn-8p for 25965@debbugs.gnu.org; Wed, 08 Mar 2017 16:52:29 -0500 Received: from ceviche.home (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id v28LqD7e001782; Wed, 8 Mar 2017 16:52:13 -0500 Received: by ceviche.home (Postfix, from userid 20848) id 8AA0B6627C; Wed, 8 Mar 2017 16:52:13 -0500 (EST) From: Stefan Monnier Message-ID: References: <87efydcvvr.fsf@luca> Date: Wed, 08 Mar 2017 16:52:13 -0500 In-Reply-To: <87efydcvvr.fsf@luca> (Andreas Politz's message of "Sat, 04 Mar 2017 09:02:32 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 2 Rules triggered EDT_SA_DN_PASS=0, RV5967=0 X-NAI-Spam-Version: 2.3.0.9418 : core <5967> : inlines <5732> : streams <1736096> : uri <2389262> X-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.3 (-) > 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. Hmm... indeed that looks odd, and maybe just removing the second ,form is the right fix. Daniel, do you happen to remember what the second ,form above is meant to do? Stefan From unknown Sun Jun 22 00:20:53 2025 X-Loop: help-debbugs@gnu.org Subject: bug#25965: 26.0.50; iter-lambda may evaluate certain forms twice Resent-From: Daniel Colascione Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 08 Mar 2017 22:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25965 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Stefan Monnier Cc: 25965@debbugs.gnu.org, Andreas Politz Received: via spool by 25965-submit@debbugs.gnu.org id=B25965.14890108984522 (code B ref 25965); Wed, 08 Mar 2017 22:09:02 +0000 Received: (at 25965) by debbugs.gnu.org; 8 Mar 2017 22:08:18 +0000 Received: from localhost ([127.0.0.1]:46803 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cljko-0001As-0Z for submit@debbugs.gnu.org; Wed, 08 Mar 2017 17:08:18 -0500 Received: from dancol.org ([96.126.100.184]:55290) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cljkl-0001Aj-P3 for 25965@debbugs.gnu.org; Wed, 08 Mar 2017 17:08:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dancol.org; s=x; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:References:Subject:Cc:To:From; bh=vH1Tdv4HUJlfis7auenBWSNQyl/IXxhJAKHdWX9Bb8M=; b=ZVc8GeSx91ge5yBmf9+YIBc+9/S2zO17cWDFERBIiqC9rDAn7Kj3HTpeZwxthaJ+3FL45nl9Hk+k+og1R2sl2Bc5TTWlZ2o5wUVsZYhv1k7/bdrUJC92nQsEJMMLfSNa1xhiuMUuEO+qmjYBEqdksUeXFqWEXFyXrLc7gqAkV2eYcVyjBS0CPy8TiK16i4JlFbcezCXoiKj6uhR9uunAbniqdYjTDZmQYyr29G55TCkoUVDI6f5YIwML4wr+NjczyialDaCg9Duyltlr6Wp41mHs6/bJWSwc63Qhe6qfhQTiTOPFnHA/i/4WRZV+2Ab9cqdru6G+je7i5s4IlxwRYg==; Received: from [2620:0:1009:a:5117:f2bd:1232:5ea7] (helo=thule.roam.corp.google.com) by dancol.org with esmtpsa (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.84_2) (envelope-from ) id 1cljkk-0000Yr-Af; Wed, 08 Mar 2017 14:08:14 -0800 From: Daniel Colascione References: <87efydcvvr.fsf@luca> Date: Wed, 08 Mar 2017 14:08:07 -0800 In-Reply-To: (Stefan Monnier's message of "Wed, 08 Mar 2017 16:52:13 -0500") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On Wed, Mar 08 2017, Stefan Monnier wrote: >> 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. > > Hmm... indeed that looks odd, and maybe just removing the second ,form > is the right fix. Daniel, do you happen to remember what the second > ,form above is meant to do? Embarrass me years later? :-) I think it's safe to remove it. Let's make sure to add a test too. From unknown Sun Jun 22 00:20:53 2025 X-Loop: help-debbugs@gnu.org Subject: bug#25965: 26.0.50; iter-lambda may evaluate certain forms twice Resent-From: Gemini Lasswell Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 21 Sep 2017 21:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25965 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Daniel Colascione Cc: 25965@debbugs.gnu.org, Stefan Monnier , Andreas Politz Received: via spool by 25965-submit@debbugs.gnu.org id=B25965.150602980918329 (code B ref 25965); Thu, 21 Sep 2017 21:37:02 +0000 Received: (at 25965) by debbugs.gnu.org; 21 Sep 2017 21:36:49 +0000 Received: from localhost ([127.0.0.1]:51946 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dv99N-0004lU-BZ for submit@debbugs.gnu.org; Thu, 21 Sep 2017 17:36:49 -0400 Received: from aibo.runbox.com ([91.220.196.211]:60874) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dv99K-0004lC-U1; Thu, 21 Sep 2017 17:36:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=rbselector1; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From; bh=vUTe7cnEW7nlMlAskKI4ShhO0ZHkXikuK6Ohk4YAR6A=; b=ZmSA4q/PSsVeahhqR+7nQs5g5i 2siDWYT3rnvl36AHz5j1slRKUFDpdTQ1cgjVfl1I0b29jEogT3pnS5YRQpsWvFVQbXY/VMuvBiGat WdQ4wo1NYW0Tmx9eISiZd5mn1HVCD9tJQJ0xj8OZp1c1AJAXygFEAXItmeYlr6psziF4b7XS2KQJP 73M6a92f66KY/IMP73lVpAgwUtgHhIR8QlPqtbKSp8yqtUXVr8Ho+UN2fYtpfSNeQ/w9iwu4ezWjJ RmI5bVE7g1giYlqjKlmynljImFKdrjG8/vUnsb0rxgVHkm8BLiRr4NtCy3eity+i36DOwzddJHQPS zqtONr8A==; Received: from [10.9.9.210] (helo=mailfront10.runbox.com) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1dv99E-0006D8-Ks; Thu, 21 Sep 2017 23:36:40 +0200 Received: from c-24-22-244-161.hsd1.wa.comcast.net ([24.22.244.161] helo=chinook) by mailfront10.runbox.com with esmtpsa (uid:179284 ) (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) id 1dv99B-0001RQ-40; Thu, 21 Sep 2017 23:36:37 +0200 From: Gemini Lasswell References: <87efydcvvr.fsf@luca> Date: Thu, 21 Sep 2017 14:36:34 -0700 In-Reply-To: (Daniel Colascione's message of "Wed, 08 Mar 2017 14:08:07 -0800") Message-ID: <87r2uzwx7h.fsf@runbox.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.60 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --=-=-= Content-Type: text/plain tags 25965 patch quit Daniel Colascione writes: > I think it's safe to remove it. Let's make > sure to add a test too. Here's a patch which removes the second ,form and adds a test: --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=0001-Fix-dynamic-binding-wrapper-in-iter-lambda-bug-25965.patch >From 46720f235ff11f64a35b91e74110fd3a8e01be4f Mon Sep 17 00:00:00 2001 From: Gemini Lasswell Date: Wed, 20 Sep 2017 10:17:35 -0700 Subject: [PATCH] Fix dynamic binding wrapper in iter-lambda (bug#25965) * lisp/emacs-lisp/generator.el (cps--make-dynamic-binding-wrapper): Remove extra evaluation of form. * test/lisp/emacs-lisp/generator-tests.el (cps-iter-lambda-with-dynamic-binding): New test. --- lisp/emacs-lisp/generator.el | 3 +-- test/lisp/emacs-lisp/generator-tests.el | 10 ++++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lisp/emacs-lisp/generator.el b/lisp/emacs-lisp/generator.el index f3597cc387..3e9885900c 100644 --- a/lisp/emacs-lisp/generator.el +++ b/lisp/emacs-lisp/generator.el @@ -142,8 +142,7 @@ cps--make-dynamic-binding-wrapper `(let ((,dynamic-var ,static-var)) (unwind-protect ; Update the static shadow after evaluation is done ,form - (setf ,static-var ,dynamic-var)) - ,form))) + (setf ,static-var ,dynamic-var))))) (defmacro cps--with-dynamic-binding (dynamic-var static-var &rest body) "Evaluate BODY such that generated atomic evaluations run with diff --git a/test/lisp/emacs-lisp/generator-tests.el b/test/lisp/emacs-lisp/generator-tests.el index 4cc6c841da..cbb136ae91 100644 --- a/test/lisp/emacs-lisp/generator-tests.el +++ b/test/lisp/emacs-lisp/generator-tests.el @@ -282,3 +282,13 @@ cps-test-closed-flag (ert-deftest cps-test-declarations-preserved () (should (equal (documentation 'generator-with-docstring) "Documentation!")) (should (equal (get 'generator-with-docstring 'lisp-indent-function) 5))) + +(ert-deftest cps-iter-lambda-with-dynamic-binding () + "`iter-lambda' with dynamic binding produces correct result (bug#25965)." + (should (= 1 + (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.14.1 --=-=-=-- From unknown Sun Jun 22 00:20:53 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Andreas Politz Subject: bug#25965: closed (Re: bug#25965: 26.0.50; iter-lambda may evaluate certain forms twice) Message-ID: References: <87h8vd5q5g.fsf@runbox.com> <87efydcvvr.fsf@luca> X-Gnu-PR-Message: they-closed 25965 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 25965@debbugs.gnu.org Date: Thu, 05 Oct 2017 19:53:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1507233182-13717-1" This is a multi-part message in MIME format... ------------=_1507233182-13717-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #25965: 26.0.50; iter-lambda may evaluate certain forms twice=20 which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 25965@debbugs.gnu.org. --=20 25965: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D25965 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1507233182-13717-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 25965-done) by debbugs.gnu.org; 5 Oct 2017 19:52:46 +0000 Received: from localhost ([127.0.0.1]:51792 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e0CCM-0003Yj-Ky for submit@debbugs.gnu.org; Thu, 05 Oct 2017 15:52:46 -0400 Received: from aibo.runbox.com ([91.220.196.211]:56690) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e0CCK-0003Ya-9b for 25965-done@debbugs.gnu.org; Thu, 05 Oct 2017 15:52:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=rbselector1; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From; bh=p6nyqxEyH5vDBZpyi1psmzPLXxyNjUcLfpKUkQlGu10=; b=CJcmL99D0i6LO5jR2/plw7qTgl OCa27eDqSQ7Tm09hduZz4jUCjNsTdxPIUYGZEOy7QRMZ0auOPJyxe/cq15Fve8B3WKHYC8bZei64y +uKmU3iHuMvdsFSgVLORCuYrwmpePkgBut1yoSCYe3ecx+U/2aLG4IUts8QraJv8Mr0GtfYh6f9Xc RihB+UJMSkREDpOK5V0bfO7U7f9s9dzQRWxRAhLMkvvwe8JvoBgut+X9tcjDqjM5Iuhl2tn4EcmM8 o3QX20x+nHwN015YAJpBAnpUMqmB4tWqmTjJlajrgZu0pjnXEONymjbiADZynNHMzVvv/y64EDX/W cP4GnJQQ==; Received: from [10.9.9.212] (helo=mailfront12.runbox.com) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1e0CCC-0000Td-UL; Thu, 05 Oct 2017 21:52:37 +0200 Received: from c-24-22-244-161.hsd1.wa.comcast.net ([24.22.244.161] helo=chinook) by mailfront12.runbox.com with esmtpsa (uid:179284 ) (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) id 1e0CBa-0002SA-Eu; Thu, 05 Oct 2017 21:51:58 +0200 From: Gemini Lasswell To: Daniel Colascione Subject: Re: bug#25965: 26.0.50; iter-lambda may evaluate certain forms twice References: <87efydcvvr.fsf@luca> <87r2uzwx7h.fsf@runbox.com> Date: Thu, 05 Oct 2017 12:51:55 -0700 In-Reply-To: <87r2uzwx7h.fsf@runbox.com> (Gemini Lasswell's message of "Thu, 21 Sep 2017 14:36:34 -0700") Message-ID: <87h8vd5q5g.fsf@runbox.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.60 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 25965-done Cc: 25965-done@debbugs.gnu.org, Stefan Monnier , Andreas Politz X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Pushed to emacs-26. ------------=_1507233182-13717-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 4 Mar 2017 08:03:02 +0000 Received: from localhost ([127.0.0.1]:39090 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ck4ec-0006Z6-GS for submit@debbugs.gnu.org; Sat, 04 Mar 2017 03:03:02 -0500 Received: from eggs.gnu.org ([208.118.235.92]:49809) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ck4eZ-0006Yb-6i for submit@debbugs.gnu.org; Sat, 04 Mar 2017 03:02:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ck4eT-0005Yj-AN for submit@debbugs.gnu.org; Sat, 04 Mar 2017 03:02:54 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:46455) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ck4eT-0005YZ-7p for submit@debbugs.gnu.org; Sat, 04 Mar 2017 03:02:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40777) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ck4eR-0006w5-Qg for bug-gnu-emacs@gnu.org; Sat, 04 Mar 2017 03:02:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ck4eO-0005Wz-O3 for bug-gnu-emacs@gnu.org; Sat, 04 Mar 2017 03:02:51 -0500 Received: from gateway-a.fh-trier.de ([143.93.54.181]:47764) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ck4eO-0005Wj-Cr for bug-gnu-emacs@gnu.org; Sat, 04 Mar 2017 03:02:48 -0500 X-Virus-Scanned: by Amavisd-new + McAfee uvscan + ClamAV [Rechenzentrum Hochschule Trier (RZ/HT)] Received: from localhost (ip5f5bdeea.dynamic.kabel-deutschland.de [95.91.222.234]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: politza) by gateway-a.fh-trier.de (Postfix) with ESMTPSA id 9496817972CD for ; Sat, 4 Mar 2017 09:02:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha1; c=simple/simple; d=hochschule-trier.de; s=default; t=1488614552; bh=b+gDDiSqmZC9DIpKoPH/ZyX10t4=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=OAAjVBkJlI+1NsJ16w09yrqDdnokIRGUbZfcL2rxXkgxngBek2zNiDTe+IVOVni1o 0p8okvTo5h55Eoh8APNhWh3ujUmcMZJiUBwndDUo2jfiqriz8d0iA2bV3oVsQoY3rz aQvB+UFWbqk9EXR0k6559+eQPoMsC/SLoCDhGElY= From: Andreas Politz To: bug-gnu-emacs@gnu.org Subject: 26.0.50; iter-lambda may evaluate certain forms twice Date: Sat, 04 Mar 2017 09:02:32 +0100 Message-ID: <87efydcvvr.fsf@luca> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) 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 ------------=_1507233182-13717-1--