From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Andreas Politz Newsgroups: gmane.emacs.bugs Subject: bug#25965: 26.0.50; iter-lambda may evaluate certain forms twice Date: Sat, 04 Mar 2017 09:02:32 +0100 Message-ID: <87efydcvvr.fsf@luca> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1488614652 30308 195.159.176.226 (4 Mar 2017 08:04:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 4 Mar 2017 08:04:12 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) To: 25965@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Mar 04 09:04:07 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ck4fd-00079I-EG for geb-bug-gnu-emacs@m.gmane.org; Sat, 04 Mar 2017 09:04:05 +0100 Original-Received: from localhost ([::1]:34346 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ck4fj-00076O-Mn for geb-bug-gnu-emacs@m.gmane.org; Sat, 04 Mar 2017 03:04:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41033) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ck4fd-00076F-4Q for bug-gnu-emacs@gnu.org; Sat, 04 Mar 2017 03:04:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ck4fa-0005s5-2Q for bug-gnu-emacs@gnu.org; Sat, 04 Mar 2017 03:04:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:40891) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ck4fZ-0005s0-VA for bug-gnu-emacs@gnu.org; Sat, 04 Mar 2017 03:04:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ck4fZ-0006aK-Ol for bug-gnu-emacs@gnu.org; Sat, 04 Mar 2017 03:04:01 -0500 X-Loop: help-debbugs@gnu.org 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: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.148861458225245 (code B ref -1); Sat, 04 Mar 2017 08:04:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 4 Mar 2017 08:03:02 +0000 Original-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 Original-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 Original-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 Original-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 Original-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 Original-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 Original-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)] Original-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= 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:130152 Archived-At: 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