From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Quek Yu Han Newsgroups: gmane.emacs.bugs Subject: bug#33890: 27.0.50; Incorrect behaviour of cl-loop macro Date: Thu, 27 Dec 2018 04:28:59 -0500 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1545932117 12756 195.159.176.226 (27 Dec 2018 17:35:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 27 Dec 2018 17:35:17 +0000 (UTC) To: 33890@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Dec 27 18:35:12 2018 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 1gcZYp-00035o-IX for geb-bug-gnu-emacs@m.gmane.org; Thu, 27 Dec 2018 18:35:07 +0100 Original-Received: from localhost ([127.0.0.1]:54472 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gcZaw-00030C-6c for geb-bug-gnu-emacs@m.gmane.org; Thu, 27 Dec 2018 12:37:18 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:32903) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gcZah-0002xr-Sj for bug-gnu-emacs@gnu.org; Thu, 27 Dec 2018 12:37:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gcZag-0006vr-Mv for bug-gnu-emacs@gnu.org; Thu, 27 Dec 2018 12:37:03 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:46521) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gcZaf-0006sL-VY for bug-gnu-emacs@gnu.org; Thu, 27 Dec 2018 12:37:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gcZaf-0006Pd-O4 for bug-gnu-emacs@gnu.org; Thu, 27 Dec 2018 12:37:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Quek Yu Han Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 27 Dec 2018 17:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 33890 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.154593219524609 (code B ref -1); Thu, 27 Dec 2018 17:37:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 27 Dec 2018 17:36:35 +0000 Original-Received: from localhost ([127.0.0.1]:39515 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gcZaF-0006Or-1D for submit@debbugs.gnu.org; Thu, 27 Dec 2018 12:36:35 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:57653) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gcRyY-0006Ha-MM for submit@debbugs.gnu.org; Thu, 27 Dec 2018 04:29:11 -0500 Original-Received: from lists.gnu.org ([208.118.235.17]:40504) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gcRyT-0007RX-92 for submit@debbugs.gnu.org; Thu, 27 Dec 2018 04:29:05 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:40126) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gcRyR-0003wv-K9 for bug-gnu-emacs@gnu.org; Thu, 27 Dec 2018 04:29:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gcRyQ-0007ED-4w for bug-gnu-emacs@gnu.org; Thu, 27 Dec 2018 04:29:03 -0500 Original-Received: from mail-yb1-xb30.google.com ([2607:f8b0:4864:20::b30]:41791) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gcRyP-00079Y-Ry for bug-gnu-emacs@gnu.org; Thu, 27 Dec 2018 04:29:02 -0500 Original-Received: by mail-yb1-xb30.google.com with SMTP id j10so4079776ybj.8 for ; Thu, 27 Dec 2018 01:29:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:mime-version:date:message-id:subject:to :content-transfer-encoding; bh=MwXJyW1smoQSmWW0cRiq68GDc69dgK7Aad6tCkM95Sc=; b=QNvjsAHZ4rxF571rc+VWvpZcBHzwDQnx0AO0JJRscrwfaB+pWdKrDxr4vZVCX9Q4Wd 0tiafNEhqUjA8zwRcqHOpvyjLGAA6AAV/5qpSGGoFPXkc+uMj1OKKAsqbDf/YPSzUx6/ qzmw0fNF9/YhmsB6Ekcfz0U70fPRbyjZWuautzO4ArXZK/QYv0cVy5Pfy+DzRF2r4cyI fROfUjDWYDVvADlKG7XjaVQw69o3EYq83377SOqwPJh+GD6Xa4vemXhJWJTcKKiVY2gg I71hoo/D0MQeGJggrbjS1D66zek88/0rDRqcUOf0DKN6B2JAK6ihmwNVlOyM/qoCcenD nV/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:mime-version:date:message-id:subject:to :content-transfer-encoding; bh=MwXJyW1smoQSmWW0cRiq68GDc69dgK7Aad6tCkM95Sc=; b=Qp7ptAodmpVa2+47iG5TiiQcsyJru3YyL85UXEciNaYNBFq8GX02TJfscT5L2/7dYB 1JBBT+JYoXnlbJPgXE6wi0LWTwJjl9p5X1mkl0ZsY3R+hbbY43sUsF1i01k5IqbKc+jQ VibtUuCMc44deBPEtcW/BBM2JhRk3qYXpBHJrgWCE9wxr2PBcEFygmixwRTA5EGAaY/U gqA4Kc6gJOgrYx3tYFyoucIfKuXv+NKxYN2x9Ts9HLh5E5FA1ttiaVGI9QD05wtbIpqP wKauSDUHjLnFvlTY5d+UuXkzrZMBPJQ2a31gNXPbf6GLEBtjaZ0dYpsX/R6kpP46xqXu e3FA== X-Gm-Message-State: AJcUukccwGyxZs8USWpV1v1shODTtRvf4DqUQq1wqq791dwAgu8zLui8 epbhTp8SswOICeaKUAcHv1WfX/drSY1gMlVZ3hwG8A== X-Google-Smtp-Source: ALg8bN46Qz8LySNguxArxZcvOQ0s449Up58knvlit5f8q2kL7HnHFFF6wcWEn3NxKKHLMtkAl45F8XALvoklmZtO/HA= X-Received: by 2002:a25:98c4:: with SMTP id m4mr11294967ybo.214.1545902940163; Thu, 27 Dec 2018 01:29:00 -0800 (PST) Original-Received: from 1058052472880 named unknown by gmailapi.google.com with HTTPREST; Thu, 27 Dec 2018 04:28:59 -0500 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Mailman-Approved-At: Thu, 27 Dec 2018 12:36:33 -0500 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:153919 Archived-At: It appears that a change to the `cl-loop` macro in Emacs 27 introduced a bug where certain clauses would be evaluated more than once in a loop with a "when" clause. See the following minimal example which finds the index of an element in a list: (cl-loop =C2=A0for x in '(a b c d e) =C2=A0for index =3D 0 then (1+ index) =C2=A0when (eq x 'e) =C2=A0return index) In Emacs 26.1 this returns `4` as expected, but in Emacs 27.0.50 it returns `7`, due to the index being incremented twice per loop. The same occurs after a `emacs -Q` restart. For reference here is the macroexpanded form of the above expression, with the difference between 26 and 27 outlined (everything else is identical): (cl-block nil =C2=A0 (let* ((--cl-var-- '(a b c d e)) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(x nil) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(index nil) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(--cl-var-- t) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(--cl-var-- t) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0--cl-var--) =C2=A0 =C2=A0 (while (and (consp --cl-var--) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (progn =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq x (car= --cl-var--)) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq index =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 (if --cl-var-- 0 (1+ index))) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (if (eq x 'e= ) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 (setq --cl-var-- index =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 --cl-var-- nil) =C2=A0 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3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D =C2=A0 =C2=A0 =C2=A0 (setq --cl-var-- nil)) =C2=A0 =C2=A0 --cl-var--)) Thanks! In GNU Emacs 27.0.50 (build 1, x86_64-apple-darwin17.6.0, NS appkit-1561.40 Version 10.13.5 (Build 17F77)) =C2=A0of 2018-07-08 built on QYH.local Repository revision: 98463bed07ecc9057094928ffdc2321eaaf3ab52 Windowing system distributor 'Apple', version 10.3.1671 System Description: =C2=A0Mac OS X 10.14.2 Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Configured using: =C2=A0'configure --disable-dependency-tracking --disable-silent-rules =C2=A0--enable-locallisppath=3D/usr/local/share/emacs/site-lisp =C2=A0--infodir=3D/usr/local/Cellar/emacs-plus/HEAD-98463be/share/info/emac= s =C2=A0--prefix=3D/usr/local/Cellar/emacs-plus/HEAD-98463be --with-xml2 =C2=A0--without-dbus --with-gnutls --with-imagemagick --with-modules =C2=A0--with-rsvg --with-xwidgets --with-ns --disable-ns-self-contained' Configured features: RSVG IMAGEMAGICK NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES THREADS XWIDGETS LCMS2 Important settings: =C2=A0 value of $LC_ALL: en_US.UTF-8 =C2=A0 value of $LC_CTYPE: UTF-8 =C2=A0 value of $LANG: en_US.UTF-8 =C2=A0 locale-coding-system: utf-8-unix Major mode: Lisp Interaction Minor modes in effect: =C2=A0 tooltip-mode: t =C2=A0 global-eldoc-mode: t =C2=A0 eldoc-mode: t =C2=A0 electric-indent-mode: t =C2=A0 mouse-wheel-mode: t =C2=A0 tool-bar-mode: t =C2=A0 menu-bar-mode: t =C2=A0 file-name-shadow-mode: t =C2=A0 global-font-lock-mode: t =C2=A0 font-lock-mode: t =C2=A0 blink-cursor-mode: t =C2=A0 auto-composition-mode: t =C2=A0 auto-encryption-mode: t =C2=A0 auto-compression-mode: t =C2=A0 line-number-mode: t =C2=A0 transient-mark-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message rmc puny seq byte-opt gv bytecomp byte-compile cconv dired dired-loaddefs format-spec rfc822 mml easymenu mml-sec password-cache epa derived epg epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils elec-pair time-date tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/ns-win ns-win ucs-normalize mule-util term/common-win tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote xwidget-internal kqueue cocoa ns lcms2 multi-tty make-network-process emacs) Memory information: ((conses 16 203880 9574) =C2=A0(symbols 48 20001 1) =C2=A0(miscs 40 33 114) =C2=A0(strings 32 28869 1418) =C2=A0(string-bytes 1 768776) =C2=A0(vectors 16 35252) =C2=A0(vector-slots 8 725502 18860) =C2=A0(floats 8 47 69) =C2=A0(intervals 56 230 0) =C2=A0(buffers 992 11))