From unknown Mon Aug 18 14:21:49 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#29799 <29799@debbugs.gnu.org> To: bug#29799 <29799@debbugs.gnu.org> Subject: Status: 24.5; cl-loop guard clause missing Reply-To: bug#29799 <29799@debbugs.gnu.org> Date: Mon, 18 Aug 2025 21:21:49 +0000 retitle 29799 24.5; cl-loop guard clause missing reassign 29799 emacs submitter 29799 Tino Calancha severity 29799 normal tag 29799 fixed thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 21 04:38:41 2017 Received: (at submit) by debbugs.gnu.org; 21 Dec 2017 09:38:41 +0000 Received: from localhost ([127.0.0.1]:45211 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eRxJJ-00066w-2K for submit@debbugs.gnu.org; Thu, 21 Dec 2017 04:38:41 -0500 Received: from eggs.gnu.org ([208.118.235.92]:47677) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eRxJI-00066l-3K for submit@debbugs.gnu.org; Thu, 21 Dec 2017 04:38:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eRxJC-0006l3-8w for submit@debbugs.gnu.org; Thu, 21 Dec 2017 04:38:35 -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.5 required=5.0 tests=BAYES_05,FREEMAIL_FROM, FREEMAIL_REPLY,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:51183) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eRxJC-0006kq-5h for submit@debbugs.gnu.org; Thu, 21 Dec 2017 04:38:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38614) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eRxJA-0003Cb-W4 for bug-gnu-emacs@gnu.org; Thu, 21 Dec 2017 04:38:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eRxJ7-0006h8-22 for bug-gnu-emacs@gnu.org; Thu, 21 Dec 2017 04:38:33 -0500 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]:39520) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eRxJ6-0006gI-Qj for bug-gnu-emacs@gnu.org; Thu, 21 Dec 2017 04:38:28 -0500 Received: by mail-wm0-x22b.google.com with SMTP id i11so14510652wmf.4 for ; Thu, 21 Dec 2017 01:38:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=2TkR1DMfxHBbut4j/NtAHcJsiIonaG6dcTVK4iQms+s=; b=H7t6ZRsLfGhLSSs2NdaPAfcj2FDknYguPEHq25fB9s29N+DQ3wwsd29sMRMhmQe7t7 4A46Ha+YRvjnxFLosf+4PY05myMh2gz6zyhBsoR8WCILCFPXFN/AIYjY/ll8T5QMj8SF kGelf/fRmPB+ZMHoEfISvj4W9JeVqydgXv4yIEokPTfHRmJaUm359M2s3KH4PMCux2A0 JzgcNpmTyKXOEHlvQDVtHUq2xVSHAuAgILnF0DQoi1SAyF1I07IkzOBUooyN1luOqq2f bwsIf9POeS4TFHXKUiwreEPr2fuivK97xslCvJ8K66UyzC08ko1TM9O960r2wBxiD417 jDnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=2TkR1DMfxHBbut4j/NtAHcJsiIonaG6dcTVK4iQms+s=; b=bYUu0yi1n92pMRuCkj3XBt9SkYTjrLYPJMG0nw5SXyrdCNnifTI/4JPcV5nn/NPpEH DJ3iZGKIkl6SRrwlyEB2s5O37M39QUvTRIgVlWE/6QJaQWZ/cLdo7ezXSih5cC6eUCJr /ytjuV4tK2ISNvS6pyiJ1BUXos6Ti8dEP5aUiGM1Ho0iz4tsG9IjaqxwRkHBUrMhAgQ+ d4vKCVd+Kj3tF3csy18O5tIAddfYvv+l4hqhSyqhSvc+ZK1lI9K+NDFsjwTDdUxvlL7A ikVmLxqjK73ZS7BGNwvY8kjqUmSRbdb5LqyCaohjC9o+O4HgPCM7u78BxIzMNayl6hiG et9Q== X-Gm-Message-State: AKGB3mIYOdHlBC2LQjJA6QaSj6CQsg39xj4NDiL55YcVc6z2kkz7Jr9k nWzRu+nXENeItm5i5h95+SigYQ== X-Google-Smtp-Source: ACJfBovMbpW4Q7hf7gyFrdDeZC8PPUp3WzMnpUyJbCnIuBB0GxaAEgfdnLtTEp9XW/RSfVC8LDEV2w== X-Received: by 10.28.220.215 with SMTP id t206mr8756853wmg.75.1513849107043; Thu, 21 Dec 2017 01:38:27 -0800 (PST) Received: from calancha-pc (228.red-83-40-68.dynamicip.rima-tde.net. [83.40.68.228]) by smtp.gmail.com with ESMTPSA id a23sm3974846wra.70.2017.12.21.01.38.25 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Dec 2017 01:38:26 -0800 (PST) From: Tino Calancha To: bug-gnu-emacs@gnu.org Subject: 24.5; cl-loop guard clause missing Date: Thu, 21 Dec 2017 18:38:20 +0900 Message-ID: <87d138beur.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain 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-Received-From: 2001:4830:134:3::11 X-Spam-Score: -3.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 (----) X-Debbugs-CC: monnier@iro.umontreal.ca,npostavs@gmail.com Consider the following snippet code: --8<-----------------------------cut here---------------start------------->8--- (require 'cl-lib) (let* ((size 7) (arr (make-vector size 0))) (cl-loop for k below size for x = (* 2 k) and y = (1+ (elt arr k)) collect (list k x y))) --8<-----------------------------cut here---------------end--------------->8--- When you execute the form above it fails because the loop overrun `arr'. The equivalent code in CL works: --8<-----------------------------cut here---------------start------------->8--- (let* ((size 7) (arr (make-array size :initial-element 0))) (loop :for k :below size :for x = (* 2 k) :and y = (1+ (elt arr k)) :collect (list k x y))) --8<-----------------------------cut here---------------end--------------->8--- * The expansion of `loop' in CL checks the condition (>= k 7) right before update the internal variables (`x' and `y'). * The expansion of `cl-loop' instead, doesn't check the condition before update the vars => in the code above we overrun `arr'. In GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.11) of 2017-09-12 on hullmann, modified by Debian Windowing system distributor `The X.Org Foundation', version 11.0.11902000 System Description: Debian GNU/Linux 9.3 (stretch) From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 01 16:46:40 2018 Received: (at 29799) by debbugs.gnu.org; 1 Jan 2018 21:46:40 +0000 Received: from localhost ([127.0.0.1]:60248 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eW7uq-00059b-N3 for submit@debbugs.gnu.org; Mon, 01 Jan 2018 16:46:40 -0500 Received: from mail-it0-f47.google.com ([209.85.214.47]:43602) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eW7uo-00059P-Qo for 29799@debbugs.gnu.org; Mon, 01 Jan 2018 16:46:39 -0500 Received: by mail-it0-f47.google.com with SMTP id u62so37105867ita.2 for <29799@debbugs.gnu.org>; Mon, 01 Jan 2018 13:46:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=NZOjdB9DuNuW5y6ZXU7+UPPVxm1BbDTgJLzAx1KMhDc=; b=WUjZ92HmhYyyUmuMqLqRcNCnWUx+r5F5KSFgilN53aiLnEvE6dMQzEcqa/IrY4A4Vn xWYxoL6lqdViwOpcJTMuqcwle7I81k2qH5enGwk/CHDRR+52tVOwqdly09Eee8OnmoLH 1521N5/1eKGRR8B27r4mwnDgtC4P67Y9BKCZL29+V0F84usaJ/02jJlk3eK4HMqI5pqz ucYLBQJqrhI/Ix7IiNpRw1vkQAGKd1Q/U0uuhvrYVf03iBXmC66bH993zS5Zw6oFqmTA LWtE+Z9K1L50znfO1pfVJA4Xx4qRlCW4i1S2XIu50xruE0rUE3EM7O7+c/sLHpnLJw7G AmrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=NZOjdB9DuNuW5y6ZXU7+UPPVxm1BbDTgJLzAx1KMhDc=; b=mfM/Jgu2uuIx5T8sv4xA/x/tWT5C1QGJkT7qlceQkdqbqPvL26HLW/adC1+kisiLjo tyjqYxzBlBcjOegr1o2oX0pLlr/ncVnSpGXceHD4dnv0vWzvQ7Jc+ec8QZHmQd07fnTO cEJXLMiIXVUXSB8+JDHUUcgcMBjjm8WuzpVD4xZ8JbvJ5GA/QbHL1gxvjJgNNqIBLG2Q 2kbDv9CnBtGJq9B+MAcpJvYzfA6e02A6OLVLlCaLS5Xa2mw1jgjxy29/avrSxvAXwkit G0X4BTGxjdOcAA0I4RpU1CuUyfkl2BmlCHHDyGrf9d6R38wVBF0mgNsZjNrZOanoCzoi YyJg== X-Gm-Message-State: AKGB3mJZnp/3quXx+lxbzcC/J7ghEtzjwJX4/SmUclzIpvga/sE3004t w5CWPkYzrGjGeYZnD5/sQBI= X-Google-Smtp-Source: ACJfBovSmedX6A9Qj3fa1sX1KcaU9xKkFfH06Hac2GcacxMFwLtx7MsTKVAJbVYBHvK68aikA9HybA== X-Received: by 10.36.157.129 with SMTP id f123mr59039060itd.39.1514843193251; Mon, 01 Jan 2018 13:46:33 -0800 (PST) Received: from zebian ([45.2.119.34]) by smtp.googlemail.com with ESMTPSA id 131sm15727373itf.25.2018.01.01.13.46.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2018 13:46:32 -0800 (PST) From: Noam Postavsky To: Tino Calancha Subject: Re: bug#29799: 24.5; cl-loop guard clause missing References: <87d138beur.fsf@gmail.com> Date: Mon, 01 Jan 2018 16:46:30 -0500 In-Reply-To: <87d138beur.fsf@gmail.com> (Tino Calancha's message of "Thu, 21 Dec 2017 18:38:20 +0900") Message-ID: <874lo5tfpl.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 29799 Cc: 29799@debbugs.gnu.org, monnier@iro.umontreal.ca 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.5 (/) Tino Calancha writes: > (require 'cl-lib) > (let* ((size 7) > (arr (make-vector size 0))) > (cl-loop for k below size > for x = (* 2 k) and y = (1+ (elt arr k)) > collect (list k x y))) > > > When you execute the form above it fails because > the loop overrun `arr'. A simpler example: (require 'cl-lib) (cl-loop for k below 3 for x = (progn (message "k = %d" k) 1) and y = 1) prints k = 0 k = 1 k = 2 k = 3 in *Messages*. The expansion looks like this: (cl-block nil (let* ((k 0)) (let ((x nil) (y nil)) (let* ((--cl-var-- t)) (while (< k 3) (cl-psetq x (if --cl-var-- (progn (message "k = %d" k) 1) x) y (if --cl-var-- 1 y)) (setq k (+ k 1)) (cl-psetq x (progn (message "k = %d" k) 1) y 1) (setq --cl-var-- nil)) nil)))) I don't understand why the "then" step is put at the of the loop. The following patch (commenting out the "ands" branch) avoids doing that, and fixes this bug. But presumably there is some reason for having this code in the first place? I guess some more complicated example would be needed to show why this naive fix won't work. --- i/lisp/emacs-lisp/cl-macs.el +++ w/lisp/emacs-lisp/cl-macs.el @@ -1288,7 +1288,7 @@ cl--parse-loop-clause (then (if (eq (car cl--loop-args) 'then) (cl--pop2 cl--loop-args) start))) (push (list var nil) loop-for-bindings) - (if (or ands (eq (car cl--loop-args) 'and)) + (if nil ;(or ands (eq (car cl--loop-args) 'and)) (progn (push `(,var (if ,(or cl--loop-first-flag From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 01 17:58:50 2018 Received: (at 29799) by debbugs.gnu.org; 1 Jan 2018 22:58:50 +0000 Received: from localhost ([127.0.0.1]:60284 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eW92g-0006lJ-Ge for submit@debbugs.gnu.org; Mon, 01 Jan 2018 17:58:50 -0500 Received: from mail-io0-f176.google.com ([209.85.223.176]:39061) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eW92e-0006l6-FI for 29799@debbugs.gnu.org; Mon, 01 Jan 2018 17:58:48 -0500 Received: by mail-io0-f176.google.com with SMTP id g70so34826709ioj.6 for <29799@debbugs.gnu.org>; Mon, 01 Jan 2018 14:58:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=fJsRm0ug3tnb7CVI+3m011WdfsxonTEDCqW/X3GLbwQ=; b=NiLAKoyaOjcE9x5fRgp5rNhKhDCMWIy0LjiRIkPaNebzFSRP4WPM1Pwv8h2fChiMG4 SvcB+hK3Z/88nBsOgZTbTbek+DWfuYcz6XV4h3VnvLl9VvFfgw2nOWE2MhOL6CC2139g anOlSw80p+TS+zM+eluiM7YEgjiIZaeFJgw2RRTmDL4Yx6oeUUBvP2QtM/iZcx1QGcSU t3Gaxp3vwZkBAdX5z+xna1IPy1JTlZ/T6SSf4h6+bh9ZeVUQyJEX8mVqidokt1hs40gy Fm5W39/K73hDqGz/cHrt9HUeHBdANGADA80bIeWSGCK4DzG06ojIM9hewFeMP/WawmNV JGOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=fJsRm0ug3tnb7CVI+3m011WdfsxonTEDCqW/X3GLbwQ=; b=kLYQqj3L0D7stQs6OdVftGdClkloLpFTuDq0X/eSs9B3dcTvWkUl4BBckOdabEm0JQ fl6Cf2CPvHzcIvF1z9E0z5msb4BpZOJV/9jUBmcJ6QU4KZCdaO0BEO/J3fQoxy9GgqTT 7rReGQMZYYka7FOqgpCq4Qsb3wic24PTCnyTuFrKmdoFXWB9OKh7ghxQqadubzAKjune H3xMCUtq/AMdV49nYGLB8ZQevc1DOw5sjGYTZSOiwTbsEdTdyzFFF3pWtli2MFl/znQq IcxhkMdMHit2bbLpjQ/0omtZOFLBVRA8VdnxmaR1JuB8+MEKwvo89RlEZmL1VzU1t2bv I68w== X-Gm-Message-State: AKGB3mIdTjqrMepBdIk+/ICZg+zzyY8i840dsyI0xaplBLpyWALRJaSb JiCi3NklkjbnHI9mrcsmBnI= X-Google-Smtp-Source: ACJfBoul2atp1n60isjYDTt8WAnt+bJjQoKSdxFLmdlsyNR4r+VNP+yKR4sj4oPxQB4o+6dA6QRsZw== X-Received: by 10.107.46.97 with SMTP id i94mr21542981ioo.179.1514847522757; Mon, 01 Jan 2018 14:58:42 -0800 (PST) Received: from zebian ([45.2.119.34]) by smtp.googlemail.com with ESMTPSA id 139sm4677173itm.2.2018.01.01.14.58.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2018 14:58:42 -0800 (PST) From: Noam Postavsky To: Tino Calancha Subject: Re: bug#29799: 24.5; cl-loop guard clause missing References: <87d138beur.fsf@gmail.com> <874lo5tfpl.fsf@users.sourceforge.net> Date: Mon, 01 Jan 2018 17:58:40 -0500 In-Reply-To: <874lo5tfpl.fsf@users.sourceforge.net> (Noam Postavsky's message of "Mon, 01 Jan 2018 16:46:30 -0500") Message-ID: <871sj9tcdb.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 29799 Cc: 29799@debbugs.gnu.org, monnier@iro.umontreal.ca 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.5 (/) Noam Postavsky writes: > I don't understand why the "then" step is put at the of the loop. The > following patch (commenting out the "ands" branch) avoids doing that, > and fixes this bug. But presumably there is some reason for having this > code in the first place? I guess some more complicated example would be > needed to show why this naive fix won't work. Oh, 'make -C test cl-macs-tests' provides some. And I see we've in fact been over this naive solution before: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=6583#28 From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 03 05:35:07 2018 Received: (at 29799) by debbugs.gnu.org; 3 Jan 2018 10:35:07 +0000 Received: from localhost ([127.0.0.1]:33828 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eWgO3-0000YG-1L for submit@debbugs.gnu.org; Wed, 03 Jan 2018 05:35:07 -0500 Received: from mail-wm0-f41.google.com ([74.125.82.41]:35362) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eWgNz-0000Xh-V7 for 29799@debbugs.gnu.org; Wed, 03 Jan 2018 05:35:04 -0500 Received: by mail-wm0-f41.google.com with SMTP id a79so1893071wma.0 for <29799@debbugs.gnu.org>; Wed, 03 Jan 2018 02:35:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version; bh=okLSaCW4LZT062qbP/if8OGaMofCyAMtzp4n6EIVGjA=; b=XxvMXxQ/nEFzbRs1k0jKHEfAOg1zNpdIIfg8Q46yWUIy+NQo7A9Tjzn70uU2vmSEZ2 poW3WnURCOFX3xiqWtjD7iom7Uxz1m/EjPocuZtsCYofx+E3tBAARiICChuT+JNtr8OZ pFE34k7HMiYj+1l1XdN+5hzZRJkrQtE2K7o6md5VNJ0wJyessfBZFgwx+UNemQBHH3Fi /CXoV3FwMZbKDwb+hMzuUtEsjgZpqj9Nly9XOCeI4VGloaaHZRWXuxIz1COVEF8RJxFL sWjyoqSK7BRhtZ2b3LcKmW+t13SkRyMW2BBN1GeeslQxSZw29cL5nvHdUa8ncx26b/L4 aEYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references :user-agent:date:message-id:mime-version; bh=okLSaCW4LZT062qbP/if8OGaMofCyAMtzp4n6EIVGjA=; b=DOnB9cJiZ6kgUZe+E+IEbmKf0lwTrs205l5SXgRffUnuZ9I8xruUaD0KHw8olYdAbN /BHR4rGDlqGf4tOytb5HqV/Dz4rqHm4iepyD5z32M8KOy5ZrzSeQ+yl6h4oU2tzGpd0E NlQp11xtpQ6el63d1G40rBhlAGjZwmbPJa0gBcPv1KtwbtVMSrbH+SC5k/uftSkYzHsx MKDdmt4h+8AxitQQDIcDCTWgtu+FKaHylPtL+K4HxAj+EaJB1YUJgn5ab6eMB5g43Qq1 mzdTlo14L6s43zsIGtcFhq2kX0B6V6SwpbZIi2/S6fPfsgljbL14UKwWg64/nEkuJdbl BMPw== X-Gm-Message-State: AKGB3mLRkHFo1bQK2YAruALqVu9KF4YQj5VIj1oUtQBPs4CTzllfNJZB 8XSBkWNIKEa/n8Wh6j5dxzU= X-Google-Smtp-Source: ACJfBotTNMord2P1kfl00K5rLOfA3XiR4V6jqd1t12LwF4Bvc+BJEVukeV6EiPr8ZMb/y68KFop2dA== X-Received: by 10.28.128.214 with SMTP id b205mr1094830wmd.82.1514975698130; Wed, 03 Jan 2018 02:34:58 -0800 (PST) Received: from calancha-pc (228.red-83-40-68.dynamicip.rima-tde.net. [83.40.68.228]) by smtp.gmail.com with ESMTPSA id s187sm423478wmf.16.2018.01.03.02.34.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Jan 2018 02:34:56 -0800 (PST) From: Tino Calancha To: Noam Postavsky Subject: Re: bug#29799: 24.5; cl-loop guard clause missing In-Reply-To: <871sj9tcdb.fsf@users.sourceforge.net> (Noam Postavsky's message of "Mon, 01 Jan 2018 17:58:40 -0500") References: <87d138beur.fsf@gmail.com> <874lo5tfpl.fsf@users.sourceforge.net> <871sj9tcdb.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Date: Wed, 03 Jan 2018 19:34:51 +0900 Message-ID: <87lghfqlh0.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 29799 Cc: 29799@debbugs.gnu.org, monnier@iro.umontreal.ca 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 (/) Noam Postavsky writes: > Noam Postavsky writes: > >> I don't understand why the "then" step is put at the of the loop. The >> following patch (commenting out the "ands" branch) avoids doing that, >> and fixes this bug. But presumably there is some reason for having this >> code in the first place? I guess some more complicated example would be >> needed to show why this naive fix won't work. > > Oh, 'make -C test cl-macs-tests' provides some. And I see we've in fact > been over this naive solution before: > https://debbugs.gnu.org/cgi/bugreport.cgi?bug=6583#28 Bug#6583 requires more thinking; I couldn't find a satisfactory fix for it. For Bug#29799 I propose the patch below: * It adds a new variable `cl--loop-guard-cond' * In a for clause, rigth after update the loop var, check if the loop condition is still valid before update the remaining variables. AFAIS, this is similar to the CL expansions for these cases. --8<-----------------------------cut here---------------start------------->8--- commit 25fb3aad45ea3c545c6389c4f7bb6f1a76ebffe8 Author: Tino Calancha Date: Wed Jan 3 19:15:14 2018 +0900 Fix #Bug#29799 * lisp/emacs-lisp/cl-macs.el (cl--loop-guard-cond): New variable. (cl--parse-loop-clause): Set it non-nil if the loop contains a for/as clause. (cl-loop): After update the loop variable, update other variables only if cl--loop-guard-cond is non-nil. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs-loop-for-as-equals-and): New test. diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index f5311041cc..db1b811f38 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -892,7 +892,7 @@ cl--loop-initially (defvar cl--loop-name) (defvar cl--loop-result) (defvar cl--loop-result-explicit) (defvar cl--loop-result-var) (defvar cl--loop-steps) -(defvar cl--loop-symbol-macs) +(defvar cl--loop-symbol-macs) (defvar cl--loop-guard-cond) (defun cl--loop-set-iterator-function (kind iterator) (if cl--loop-iterator-function @@ -961,7 +961,7 @@ cl-loop (cl--loop-accum-var nil) (cl--loop-accum-vars nil) (cl--loop-initially nil) (cl--loop-finally nil) (cl--loop-iterator-function nil) (cl--loop-first-flag nil) - (cl--loop-symbol-macs nil)) + (cl--loop-symbol-macs nil) (cl--loop-guard-cond nil)) ;; Here is more or less how those dynbind vars are used after looping ;; over cl--parse-loop-clause: ;; @@ -996,7 +996,22 @@ cl-loop (list (or cl--loop-result-explicit cl--loop-result)))) (ands (cl--loop-build-ands (nreverse cl--loop-body))) - (while-body (nconc (cadr ands) (nreverse cl--loop-steps))) + (while-body + (nconc + (cadr ands) + (if (or (not cl--loop-guard-cond) (not cl--loop-first-flag)) + (nreverse cl--loop-steps) + ;; Right after update the loop variable ensure that the loop condition, + ;; i.e. (car ands), is still satisfied; otherwise do not + ;; update other variables (#Bug#29799). + ;; (last cl--loop-steps) updates the loop var + ;; (car (butlast cl--loop-steps)) sets `cl--loop-first-flag' nil + ;; (nreverse (cdr (butlast cl--loop-steps))) sets the + ;; remaining variables. + (append (last cl--loop-steps) + `((and ,(car ands) + ,@(nreverse (cdr (butlast cl--loop-steps))))) + `(,(car (butlast cl--loop-steps))))))) (body (append (nreverse cl--loop-initially) (list (if cl--loop-iterator-function @@ -1500,10 +1515,11 @@ cl--parse-loop-clause ,(cl--loop-let (nreverse loop-for-sets) 'setq ands) t) cl--loop-body)) - (if loop-for-steps - (push (cons (if ands 'cl-psetq 'setq) - (apply 'append (nreverse loop-for-steps))) - cl--loop-steps)))) + (when loop-for-steps + (setq cl--loop-guard-cond t) + (push (cons (if ands 'cl-psetq 'setq) + (apply 'append (nreverse loop-for-steps))) + cl--loop-steps)))) ((eq word 'repeat) (let ((temp (make-symbol "--cl-var--"))) diff --git a/test/lisp/emacs-lisp/cl-macs-tests.el b/test/lisp/emacs-lisp/cl-macs-tests.el index 575f170af6..2aab002964 100644 --- a/test/lisp/emacs-lisp/cl-macs-tests.el +++ b/test/lisp/emacs-lisp/cl-macs-tests.el @@ -497,4 +497,12 @@ vconcat (vector (1+ x))) [2 3 4 5 6]))) + +(ert-deftest cl-macs-loop-for-as-equals-and () + "Test for https://debbugs.gnu.org/29799 ." + (let ((arr (make-vector 3 0))) + (should (equal '((0 0) (1 1) (2 2)) + (cl-loop for k below 3 for x = k and z = (elt arr k) + collect (list k x)))))) + ;;; cl-macs-tests.el ends here --8<-----------------------------cut here---------------end--------------->8--- From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 06 08:44:05 2018 Received: (at 29799) by debbugs.gnu.org; 6 Jan 2018 13:44:05 +0000 Received: from localhost ([127.0.0.1]:37628 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eXolZ-0001Ev-Ks for submit@debbugs.gnu.org; Sat, 06 Jan 2018 08:44:05 -0500 Received: from mail-it0-f48.google.com ([209.85.214.48]:34638) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eXolY-0001EL-G6 for 29799@debbugs.gnu.org; Sat, 06 Jan 2018 08:44:04 -0500 Received: by mail-it0-f48.google.com with SMTP id m11so7086241iti.1 for <29799@debbugs.gnu.org>; Sat, 06 Jan 2018 05:44:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=/XwK+4Y+sKPpJM8qlahSLwDKAnk8PeYyqRAn7Crc0tM=; b=D8QGz6PdYC2byolIzSySHa+fpoXc14tH58SHgtjm4q6MFJyJRrw47MebjcveLsgNIe iq4R8fNtPGTGbAVDMMIJctiv/bhhDBV/x1TTlc3w7uDylKXHyr48B+N7enlx7nLvB5Fd DUvdIA2uewKTe/1LCK7Pvn/jYtObbld7mxunXPeRSXX1rwDdk/eek0FzwiqDi9wL+ao0 bdRVR9yqPEoSKFSvWBMhnIzejYLaXwOhccljwC4jXXxxr2Sqkn87a6hM2Z6QzXSh9+9S 2amrUwEgE3/h3c9hH0oDcF6AV3qpUjdUTaeDrs2VTtnlLZXmHil4wGEUXBAGD2xdNP1K 4DGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=/XwK+4Y+sKPpJM8qlahSLwDKAnk8PeYyqRAn7Crc0tM=; b=t/hlZhqVXlDcMAZRc95KLxCidGqo0XyBFl5qN51KmuiLmzgg8O/p0lvwYmsVf8LtN6 9k0+s014+A38LLuSWcgyylkGOw+ihBTH19H+4qCTmRrh0noiM85fLxv9i1s40kwqrHIh jIU1LJlBVibgHYgBuY/ObQkIwg3wCuPK7Ji4JQy0+xl8ZK6oByFpjORFlnEIG4Qra3tA bsnUBxdea6A9aG7G9Tpv3FcS7gsQvLr68n99XbOb+1Kb/jgW59bxYdki8qT/lVZa4rTY OOhEz1iFdfZVdoVVLZ5anO/NyiXJVJXrqRijMsmWJM67HM6NxFXH35xRqHCbIhaptE4T aQhQ== X-Gm-Message-State: AKGB3mKre4U8wlx9MDpKCnknIsLfBgktqwiv6+iDgwt03o0/QUaC1/U8 OPD5NgTCFFtgpSfHGVyI94M= X-Google-Smtp-Source: ACJfBov4u+T7ntk2O1IthBEAyD2pamxCbJN+sseXGuYYUkGdZHEZbKuBRnZQ4Ze2hj5R1jfFFPxmGQ== X-Received: by 10.36.185.79 with SMTP id k15mr6822169iti.82.1515246238961; Sat, 06 Jan 2018 05:43:58 -0800 (PST) Received: from zebian ([45.2.119.34]) by smtp.googlemail.com with ESMTPSA id 139sm3214176itm.2.2018.01.06.05.43.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 06 Jan 2018 05:43:57 -0800 (PST) From: Noam Postavsky To: Tino Calancha Subject: Re: bug#29799: 24.5; cl-loop guard clause missing References: <87d138beur.fsf@gmail.com> <874lo5tfpl.fsf@users.sourceforge.net> <871sj9tcdb.fsf@users.sourceforge.net> <87lghfqlh0.fsf@gmail.com> Date: Sat, 06 Jan 2018 08:43:56 -0500 In-Reply-To: <87lghfqlh0.fsf@gmail.com> (Tino Calancha's message of "Wed, 03 Jan 2018 19:34:51 +0900") Message-ID: <87shbjqezn.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 29799 Cc: 29799@debbugs.gnu.org, monnier@iro.umontreal.ca 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.5 (/) Tino Calancha writes: > Fix #Bug#29799 > > * lisp/emacs-lisp/cl-macs.el (cl--loop-guard-cond): New variable. > (cl--parse-loop-clause): Set it non-nil if the loop contains > a for/as clause. > (cl-loop): After update the loop variable, update other variables > only if cl--loop-guard-cond is non-nil. > > * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs-loop-for-as-equals-and): > New test. Looks good, but please add some more info to the summary line. From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 08 05:20:51 2018 Received: (at 29799-done) by debbugs.gnu.org; 8 Jan 2018 10:20:51 +0000 Received: from localhost ([127.0.0.1]:40226 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eYUXz-0008PZ-FD for submit@debbugs.gnu.org; Mon, 08 Jan 2018 05:20:51 -0500 Received: from mail-wr0-f179.google.com ([209.85.128.179]:45891) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eYUXx-0008PN-OE for 29799-done@debbugs.gnu.org; Mon, 08 Jan 2018 05:20:50 -0500 Received: by mail-wr0-f179.google.com with SMTP id o15so10148142wrf.12 for <29799-done@debbugs.gnu.org>; Mon, 08 Jan 2018 02:20:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version; bh=mHNReOvDCrZsI+5TdDppxhc3T4rTXs9txHAnsVTm4P0=; b=XD4tzH7cFtbkA8JAIlCOuhIs1M2bNlHc7yCw2Z9ax0sCIFV1JR89T3p+NjgWC4HwMl dgpLqTdy67n+denUrS8Uiyhy763WZg5Iax87InqhdujJXWrCepDzLbYv2psxgTcNvRW8 Hd19DV8QQida246XT6mOH3axdN2YhG3QcvvFwSxrZxuQuexahe13Nj2kt7XDYYsZhFQP TFfm4nNBshJIXUVBl8QbojYESi43x8diqk/TnBgXiQALQgFo+eCYGnibPuCytpBYOWBv lObk6SSPGHpYn0C8OXTSudMKRdPCXcNgYDWcTy84lGJpDfphH60kCg/SxaLyebQekn6q vx1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=mHNReOvDCrZsI+5TdDppxhc3T4rTXs9txHAnsVTm4P0=; b=FKG5RaLMWzjX7o/o4CgYuJrbdK4g9ER87xBLiYrT2W40dPv7/rqkUnfbsvmkxwiFWF UyEGvSjdI7uG6K+KB1HPmNO5Mg35CjqtuOn69hgaVq+4tBVw7nbGrUYo7P7SXK9ntFNv mXcqKlaWxXa9kAaOsU0chbHNqHu23WGab0xJc31+M1HLQLy6iySZ2gc44sNcq0u6nn7i ciNaneXwLziHYU0DPvhsoIN6TocBci1VGcKgcdQAKQRF9VZRF5BDA0LOU4l4g66TW3Mg YerXQ59iL/+61vSiYYSA7rt2+dQdACHKR9mYgm6tho9D+A14PqsT1UOioHTLeGbKNr8X SYhg== X-Gm-Message-State: AKGB3mKksXsVEoTd10N7CAeDr80RQ5t4V0YDdDpilO/Uk860KULi6UIB 3a5qHStOodB4Vr2262n0ou/rpQ== X-Google-Smtp-Source: ACJfBouzukTgr1UwGRjWBz+M2hEXB8LAcxgnr1xgd9QMkJXENdu/qRtGHWi6wrIFiGZhJQR2AbCPgg== X-Received: by 10.223.160.242 with SMTP id n47mr10412447wrn.35.1515406843844; Mon, 08 Jan 2018 02:20:43 -0800 (PST) Received: from calancha-pc (228.red-83-40-68.dynamicip.rima-tde.net. [83.40.68.228]) by smtp.gmail.com with ESMTPSA id x18sm4053296wrg.0.2018.01.08.02.20.42 for <29799-done@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Jan 2018 02:20:42 -0800 (PST) From: Tino Calancha To: 29799-done@debbugs.gnu.org Subject: Re: bug#29799: 24.5; cl-loop guard clause missing References: <87d138beur.fsf@gmail.com> <874lo5tfpl.fsf@users.sourceforge.net> <871sj9tcdb.fsf@users.sourceforge.net> <87lghfqlh0.fsf@gmail.com> <87shbjqezn.fsf@users.sourceforge.net> Date: Mon, 08 Jan 2018 19:20:35 +0900 In-Reply-To: <87shbjqezn.fsf@users.sourceforge.net> (Noam Postavsky's message of "Sat, 06 Jan 2018 08:43:56 -0500") Message-ID: <87r2r0ird8.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 29799-done 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 (/) Noam Postavsky writes: > Tino Calancha writes: > >> Fix #Bug#29799 >> >> * lisp/emacs-lisp/cl-macs.el (cl--loop-guard-cond): New variable. >> (cl--parse-loop-clause): Set it non-nil if the loop contains >> a for/as clause. >> (cl-loop): After update the loop variable, update other variables >> only if cl--loop-guard-cond is non-nil. >> >> * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs-loop-for-as-equals-and): >> New test. > > Looks good, but please add some more info to the summary line. Thank you very much. Extended the commit message with more detailed explanations. Fixed in master branch as commit 'cl-loop: Add missing guard condition' (a0365437c9ee308ad7978e436631020f513b25e7). From unknown Mon Aug 18 14:21:49 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 05 Feb 2018 12:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 27 23:57:07 2019 Received: (at control) by debbugs.gnu.org; 28 Oct 2019 03:57:07 +0000 Received: from localhost ([127.0.0.1]:43716 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iOw9S-0005yc-QT for submit@debbugs.gnu.org; Sun, 27 Oct 2019 23:57:07 -0400 Received: from mail-qt1-f179.google.com ([209.85.160.179]:41223) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iOw9Q-0005y1-OB for control@debbugs.gnu.org; Sun, 27 Oct 2019 23:57:05 -0400 Received: by mail-qt1-f179.google.com with SMTP id o3so12710388qtj.8 for ; Sun, 27 Oct 2019 20:57:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:to:from:subject; bh=VR/gYvdQBqZqw5RNl66+/z6B5EDouEYrI7+FtfF4GkA=; b=QcLgyMdvU8BLX/1WCdJyfKA9rTqlpizd0pIMQjGPwwurMtKrDGPLbM5d5XC0yspu+s 4W0o1tDBUuKhvuTC5Dpr+spaDdCZ6zODlKZ8KAmK7/tEJtXr7mjMDh2Ft/TlHFl1a8nm 9ewzs19TVSwPb4QjRHbZ3hnqnAKU1EgV0NFQuuI5OFVkn0WmP7M31d+8pzj1yaLVfcMo zz9v4CQJEY5UZ85XQDC0s/V0+38ugDgSbTYaQ+vwIC/cLVlXhDbq8Pcze2hFIQOo0i/Y ND2STg27uW0r9gMM7lfUB93TCunsIxOKZ4sXW1cUOXuJJy6qttU89dJjDH6dKTwSPypK Qvjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:to:from:subject; bh=VR/gYvdQBqZqw5RNl66+/z6B5EDouEYrI7+FtfF4GkA=; b=JLVf93EuWTkmeCh8Uzj5pLYNEK9l5APFwI4kCbKXJLT0xz8h+u8lDnLXMOicnuexaH QEPNxUbshw/WtqQcR+5HlUh30WRfUbf7yOszrlwROZ79O3qYugMw8cCTl23f5neKLr2x mhtpVoyTEkE2v3iAqp2q4kbCtriXTvrWgrTrJI5mQ+ETrgkCvrtC4oqNUGno5rUDahsU u9B28LjdM6tzyKgHp8hww/Op7B3z4xHDZZuBjQrB780rnpTj1iyDRS5Gr2Z+8YV2gerq kMarYVyoW76YiTggeJdq/ontPslQSnJIMTTb8qqGMjGyj0kNerAuxAXi1w7jHGRJCES2 ZafA== X-Gm-Message-State: APjAAAX0KLiB/W9EwoIwe3f0Xmi7QXWKQo4XLCEXBKE1Cwa8CVXtQeqz D/hN4UFZkk9KrVyGJ+5KA4n7Dr+h X-Google-Smtp-Source: APXvYqyWg2epWZs7g9YjthbrF54uJzzbhWI/KfJ2INPrDPfC3qk95RB0ecTzU+HtTAYyZvauLRbgVA== X-Received: by 2002:ac8:f35:: with SMTP id e50mr4070706qtk.39.1572235019147; Sun, 27 Oct 2019 20:56:59 -0700 (PDT) Received: from localhost (pool-100-33-98-8.nycmny.fios.verizon.net. [100.33.98.8]) by smtp.gmail.com with ESMTPSA id 4sm5158814qtf.87.2019.10.27.20.56.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 27 Oct 2019 20:56:58 -0700 (PDT) Message-ID: <5db6670a.1c69fb81.e11e9.bfae@mx.google.com> Date: Sun, 27 Oct 2019 23:56:58 -0400 To: control@debbugs.gnu.org From: dick Subject: control message for bug #29799 X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: control 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.0 (-) unarchive 29799 quit From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 27 23:59:50 2019 Received: (at 29799) by debbugs.gnu.org; 28 Oct 2019 03:59:51 +0000 Received: from localhost ([127.0.0.1]:43721 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iOwC6-00062e-B7 for submit@debbugs.gnu.org; Sun, 27 Oct 2019 23:59:50 -0400 Received: from mail-qt1-f177.google.com ([209.85.160.177]:44015) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iOwC4-00062R-4K for 29799@debbugs.gnu.org; Sun, 27 Oct 2019 23:59:48 -0400 Received: by mail-qt1-f177.google.com with SMTP id l15so6121024qtr.10 for <29799@debbugs.gnu.org>; Sun, 27 Oct 2019 20:59:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version; bh=BIpnmO33QbF9aqsfXa66wTKvgngulfUQoG3egNSjN4Y=; b=bi6Z2NNnAtF1t7KHYoXZ/pULfpLshBA4+S9bPcCjQMbblrP+ssERtTPypWuK4r89TX 0wT0rTz9839Xe3PqSEBiENcUDrDy+4Zu286CopBdVTlGdXqtJLoyelb223oaxJOMoHPC PApCNllK1sdykA8XKyY5HnMympbj5qiDXbn7Njyh4bt/kxIleADffihi9EiwSpwcZ5XU 72hHo6KebJj9uJ6pU3DuFR5EGqaf1bh4VoXPN5a0DGUrik7EuSFwdfPQWEE25oO+2WJm CvTYdxV2YkYsG8Yv6yZCBSZvoXspo4qd1r6baxkQMreCmNoTlkolprK7LM6wGn4Yn/1O wNMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=BIpnmO33QbF9aqsfXa66wTKvgngulfUQoG3egNSjN4Y=; b=YqNZT5cfKZxcamrAT1L5Xukg7ZwvNInuaFq9RX9/CJ48RWF65o3549yIBl2gGtNHKP Tap2VeMZkEqzLBUhRSh5+KrsPdtgBzmx052TOFUHhuhxKgI+6jID7j5Yc/DjK4IFAx0E bGtm3QtzfcOiYBgzo/MD4fti8VzI+IaOn1McRWGv2LUisP7yZRDy/2iDoPN3qt15kzen jFIMXj7jWLi8BjSHJL1RWMhuE/G9avE3xmSZxHzMjwWAGC/UUpOs4KRUh1ftb6+tUKI6 3V5L+cdGqW0F7V7PSeYxBPdA9cn7LmyTCl/JZpcbnOumErgNJm06KLjiiPvYTXVDC7WH 5Gjg== X-Gm-Message-State: APjAAAUPDlw9TRgEo/pQ1jGcMDlxol1g7bgzXMx4gcNNBEvRqOYJZrW5 syO3mrEHxCrWi0UPTUlb/wScCcUkpMc= X-Google-Smtp-Source: APXvYqxyE2deXe8hnuqbSwCpbp3zeuTFxUQDWk66IMRWFafW9y02/8omg5MSnrPuU4fkvKZt+3O8lg== X-Received: by 2002:ac8:6c9:: with SMTP id j9mr15075960qth.81.1572235182491; Sun, 27 Oct 2019 20:59:42 -0700 (PDT) Received: from localhost (pool-100-33-98-8.nycmny.fios.verizon.net. [100.33.98.8]) by smtp.gmail.com with ESMTPSA id t7sm5007652qkg.114.2019.10.27.20.59.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 27 Oct 2019 20:59:41 -0700 (PDT) From: dick.r.chiang@gmail.com To: 29799@debbugs.gnu.org Subject: Re: bug#29799: 24.5; cl-loop guard clause missing References: <87d138beur.fsf@gmail.com> Date: Sun, 27 Oct 2019 23:59:41 -0400 In-Reply-To: <87d138beur.fsf@gmail.com> (Tino Calancha's message of "Thu, 21 Dec 2017 18:38:20 +0900") Message-ID: <87a79lseoi.fsf@dick> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 29799 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.0 (-) --=-=-= Content-Type: text/plain I noticed the following cases stopped working after commit a036543. ;; should not fail (cl-loop for i from 1 upto 100 and j = 1 then (1+ j) do (cl-assert (= i j) t) until (> j 10)) ;; should return (1 0) (cl-loop with result for x below 3 for y below 2 and z = (progn (push x result) nil) finally return result) --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Refix-conditional-step-clauses-in-cl-loop.patch Content-Description: patch >From c193f58b91ce875de4b8d4d4a87fbaea8111fdf5 Mon Sep 17 00:00:00 2001 From: dickmao Date: Sun, 27 Oct 2019 16:11:48 -0400 Subject: [PATCH] Refix conditional step clauses in cl-loop Readdress (bug#29799), and add more tests. * lisp/emacs-lisp/cl-macs.el (cl--loop-bindings, cl-loop): Add cl--loop-conditions, remove cl--loop-guard-cond (cl--push-clause-loop-body, cl--parse-loop-clause): New convenience macro for tracking cl--loop-conditions (bug#29799) --- lisp/emacs-lisp/cl-macs.el | 96 +++++++++++---------------- test/lisp/emacs-lisp/cl-macs-tests.el | 77 +++++++++++++++++++-- 2 files changed, 110 insertions(+), 63 deletions(-) diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 80e218884a..a5ecf33203 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -889,7 +889,7 @@ cl-return-from ;;; The "cl-loop" macro. (defvar cl--loop-args) (defvar cl--loop-accum-var) (defvar cl--loop-accum-vars) -(defvar cl--loop-bindings) (defvar cl--loop-body) +(defvar cl--loop-bindings) (defvar cl--loop-body) (defvar cl--loop-conditions) (defvar cl--loop-finally) (defvar cl--loop-finish-flag) ;Symbol set to nil to exit the loop? (defvar cl--loop-first-flag) @@ -897,7 +897,7 @@ cl--loop-initially (defvar cl--loop-name) (defvar cl--loop-result) (defvar cl--loop-result-explicit) (defvar cl--loop-result-var) (defvar cl--loop-steps) -(defvar cl--loop-symbol-macs) (defvar cl--loop-guard-cond) +(defvar cl--loop-symbol-macs) (defun cl--loop-set-iterator-function (kind iterator) (if cl--loop-iterator-function @@ -966,7 +966,8 @@ cl-loop (cl--loop-accum-var nil) (cl--loop-accum-vars nil) (cl--loop-initially nil) (cl--loop-finally nil) (cl--loop-iterator-function nil) (cl--loop-first-flag nil) - (cl--loop-symbol-macs nil) (cl--loop-guard-cond nil)) + (cl--loop-symbol-macs nil) + (cl--loop-conditions nil)) ;; Here is more or less how those dynbind vars are used after looping ;; over cl--parse-loop-clause: ;; @@ -1001,24 +1002,7 @@ cl-loop (list (or cl--loop-result-explicit cl--loop-result)))) (ands (cl--loop-build-ands (nreverse cl--loop-body))) - (while-body - (nconc - (cadr ands) - (if (or (not cl--loop-guard-cond) (not cl--loop-first-flag)) - (nreverse cl--loop-steps) - ;; Right after update the loop variable ensure that the loop - ;; condition, i.e. (car ands), is still satisfied; otherwise, - ;; set `cl--loop-first-flag' nil and skip the remaining - ;; body forms (#Bug#29799). - ;; - ;; (last cl--loop-steps) updates the loop var - ;; (car (butlast cl--loop-steps)) sets `cl--loop-first-flag' nil - ;; (nreverse (cdr (butlast cl--loop-steps))) are the - ;; remaining body forms. - (append (last cl--loop-steps) - `((and ,(car ands) - ,@(nreverse (cdr (butlast cl--loop-steps))))) - `(,(car (butlast cl--loop-steps))))))) + (while-body (nconc (cadr ands) (nreverse cl--loop-steps))) (body (append (nreverse cl--loop-initially) (list (if cl--loop-iterator-function @@ -1051,6 +1035,12 @@ cl-loop (list `(cl-symbol-macrolet ,cl--loop-symbol-macs ,@body)))) `(cl-block ,cl--loop-name ,@body))))) +(defmacro cl--push-clause-loop-body (clause) + "Apply CLAUSE to both `cl--loop-conditions' and `cl--loop-body'." + `(progn + (push ,clause cl--loop-conditions) + (push ,clause cl--loop-body))) + ;; Below is a complete spec for cl-loop, in several parts that correspond ;; to the syntax given in CLtL2. The specs do more than specify where ;; the forms are; it also specifies, as much as Edebug allows, all the @@ -1201,8 +1191,6 @@ cl-loop ;; (def-edebug-spec loop-d-type-spec ;; (&or (loop-d-type-spec . [&or nil loop-d-type-spec]) cl-type-spec)) - - (defun cl--parse-loop-clause () ; uses loop-* (let ((word (pop cl--loop-args)) (hash-types '(hash-key hash-keys hash-value hash-values)) @@ -1281,11 +1269,11 @@ cl--parse-loop-clause (if end-var (push (list end-var end) loop-for-bindings)) (if step-var (push (list step-var step) loop-for-bindings)) - (if end - (push (list - (if down (if excl '> '>=) (if excl '< '<=)) - var (or end-var end)) - cl--loop-body)) + (when end + (cl--push-clause-loop-body + (list + (if down (if excl '> '>=) (if excl '< '<=)) + var (or end-var end)))) (push (list var (list (if down '- '+) var (or step-var step 1))) loop-for-steps))) @@ -1295,7 +1283,7 @@ cl--parse-loop-clause (temp (if (and on (symbolp var)) var (make-symbol "--cl-var--")))) (push (list temp (pop cl--loop-args)) loop-for-bindings) - (push `(consp ,temp) cl--loop-body) + (cl--push-clause-loop-body `(consp ,temp)) (if (eq word 'in-ref) (push (list var `(car ,temp)) cl--loop-symbol-macs) (or (eq temp var) @@ -1318,24 +1306,19 @@ cl--parse-loop-clause ((eq word '=) (let* ((start (pop cl--loop-args)) (then (if (eq (car cl--loop-args) 'then) - (cl--pop2 cl--loop-args) start))) + (cl--pop2 cl--loop-args) start)) + (first-assign (or cl--loop-first-flag + (setq cl--loop-first-flag + (make-symbol "--cl-var--"))))) (push (list var nil) loop-for-bindings) (if (or ands (eq (car cl--loop-args) 'and)) (progn - (push `(,var - (if ,(or cl--loop-first-flag - (setq cl--loop-first-flag - (make-symbol "--cl-var--"))) - ,start ,var)) - loop-for-sets) - (push (list var then) loop-for-steps)) - (push (list var - (if (eq start then) start - `(if ,(or cl--loop-first-flag - (setq cl--loop-first-flag - (make-symbol "--cl-var--"))) - ,start ,then))) - loop-for-sets)))) + (push `(,var (if ,first-assign ,start ,var)) loop-for-sets) + (push `(,var (if ,(car (cl--loop-build-ands + (nreverse cl--loop-conditions))) + ,then ,var)) + loop-for-steps)) + (push `(,var (if ,first-assign ,start ,then)) loop-for-sets)))) ((memq word '(across across-ref)) (let ((temp-vec (make-symbol "--cl-vec--")) @@ -1344,9 +1327,8 @@ cl--parse-loop-clause (push (list temp-vec (pop cl--loop-args)) loop-for-bindings) (push (list temp-len `(length ,temp-vec)) loop-for-bindings) (push (list temp-idx -1) loop-for-bindings) - (push `(< (setq ,temp-idx (1+ ,temp-idx)) - ,temp-len) - cl--loop-body) + (cl--push-clause-loop-body + `(< (setq ,temp-idx (1+ ,temp-idx)) ,temp-len)) (if (eq word 'across-ref) (push (list var `(aref ,temp-vec ,temp-idx)) cl--loop-symbol-macs) @@ -1376,15 +1358,14 @@ cl--parse-loop-clause loop-for-bindings) (push (list var `(elt ,temp-seq ,temp-idx)) cl--loop-symbol-macs) - (push `(< ,temp-idx ,temp-len) cl--loop-body)) + (cl--push-clause-loop-body `(< ,temp-idx ,temp-len))) ;; Evaluate seq length just if needed, that is, when seq is not a cons. (push (list temp-len (or (consp seq) `(length ,temp-seq))) loop-for-bindings) (push (list var nil) loop-for-bindings) - (push `(and ,temp-seq - (or (consp ,temp-seq) - (< ,temp-idx ,temp-len))) - cl--loop-body) + (cl--push-clause-loop-body `(and ,temp-seq + (or (consp ,temp-seq) + (< ,temp-idx ,temp-len)))) (push (list var `(if (consp ,temp-seq) (pop ,temp-seq) (aref ,temp-seq ,temp-idx))) @@ -1480,9 +1461,8 @@ cl--parse-loop-clause (push (list var '(selected-frame)) loop-for-bindings) (push (list temp nil) loop-for-bindings) - (push `(prog1 (not (eq ,var ,temp)) - (or ,temp (setq ,temp ,var))) - cl--loop-body) + (cl--push-clause-loop-body `(prog1 (not (eq ,var ,temp)) + (or ,temp (setq ,temp ,var)))) (push (list var `(next-frame ,var)) loop-for-steps))) @@ -1503,9 +1483,8 @@ cl--parse-loop-clause (push (list minip `(minibufferp (window-buffer ,var))) loop-for-bindings) (push (list temp nil) loop-for-bindings) - (push `(prog1 (not (eq ,var ,temp)) - (or ,temp (setq ,temp ,var))) - cl--loop-body) + (cl--push-clause-loop-body `(prog1 (not (eq ,var ,temp)) + (or ,temp (setq ,temp ,var)))) (push (list var `(next-window ,var ,minip)) loop-for-steps))) @@ -1529,7 +1508,6 @@ cl--parse-loop-clause t) cl--loop-body)) (when loop-for-steps - (setq cl--loop-guard-cond t) (push (cons (if ands 'cl-psetq 'setq) (apply 'append (nreverse loop-for-steps))) cl--loop-steps)))) diff --git a/test/lisp/emacs-lisp/cl-macs-tests.el b/test/lisp/emacs-lisp/cl-macs-tests.el index 09ce660a2f..8beb9d317b 100644 --- a/test/lisp/emacs-lisp/cl-macs-tests.el +++ b/test/lisp/emacs-lisp/cl-macs-tests.el @@ -30,7 +30,7 @@ ;;; ANSI 6.1.1.7 Destructuring (ert-deftest cl-macs-loop-and-assignment () - ;; Bug#6583 + "Bug#6583" :expected-result :failed (should (equal (cl-loop for numlist in '((1 2 4.0) (5 6 8.3) (8 9 10.4)) for a = (cl-first numlist) @@ -61,7 +61,6 @@ ;;; 6.1.2.1.1 The for-as-arithmetic subclause (ert-deftest cl-macs-loop-for-as-arith () "Test various for-as-arithmetic subclauses." - :expected-result :failed (should (equal (cl-loop for i to 10 by 3 collect i) '(0 3 6 9))) (should (equal (cl-loop for i upto 3 collect i) @@ -74,9 +73,9 @@ '(10 8 6))) (should (equal (cl-loop for i from 10 downto 1 by 3 collect i) '(10 7 4 1))) - (should (equal (cl-loop for i above 0 by 2 downfrom 10 collect i) + (should (equal (cl-loop for i downfrom 10 above 0 by 2 collect i) '(10 8 6 4 2))) - (should (equal (cl-loop for i downto 10 from 15 collect i) + (should (equal (cl-loop for i from 15 downto 10 collect i) '(15 14 13 12 11 10)))) (ert-deftest cl-macs-loop-for-as-arith-order-side-effects () @@ -530,4 +529,74 @@ l) '(1)))) +(ert-deftest cl-macs-loop-conditional-step-clauses () + "These tests failed under the initial fixes in #bug#29799." + (should (cl-loop for i from 1 upto 100 and j = 1 then (1+ j) + if (not (= i j)) + return nil + end + until (> j 10) + finally return t)) + + (should (equal (let* ((size 7) + (arr (make-vector size 0))) + (cl-loop for k below size + for x = (* 2 k) and y = (1+ (elt arr k)) + collect (list k x y))) + '((0 0 1) (1 2 1) (2 4 1) (3 6 1) (4 8 1) (5 10 1) (6 12 1)))) + (should (equal (cl-loop with result + for x below 3 + for y below 2 and z = 1 + collect x) + '(0 1))) + + (should (equal (cl-loop with result + for x below 3 + and y below 2 + collect x) + '(0 1))) + + ;; this is actually disallowed in clisp, but is semantically consistent + (should (equal (cl-loop with result + for x below 3 + for y = (progn (push x result) x) and z = 1 + append (list x y) into result + finally return result) + '(2 1 0 0 0 1 1 2 2))) + + ;; this is actually disallowed in clisp, but is semantically consistent + (should (equal (cl-loop with result + for x below 3 + and y = (progn (push x result) x) and z = 1 + append (list x y) into result + finally return result) + '(2 1 0 0 0 0 1 0 2 1))) + + (should (equal (cl-loop with result + for x below 3 + for y = (progn (push x result)) + finally return result) + '(2 1 0))) + + ;; this nonintuitive result is replicated by clisp + (should (equal (cl-loop with result + for x below 3 + and y = (progn (push x result)) + finally return result) + '(2 1 0 0))) + + ;; this nonintuitive result is replicated by clisp + (should (equal (cl-loop with result + for x below 3 + and y = (progn (push x result)) then (progn (push (1+ x) result)) + finally return result) + '(3 2 1 0))) + + (should (cl-loop with result + for x below 3 + for y = (progn (push x result) x) then (progn (push (1+ x) result) (1+ x)) + and z = 1 + collect y into result1 + finally return (equal (nreverse result) result1)))) + ;;; cl-macs-tests.el ends here -- 2.23.0 --=-=-=-- From unknown Mon Aug 18 14:21:49 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: Did not alter fixed versions and reopened. Date: Mon, 28 Oct 2019 04:04:01 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # Did not alter fixed versions and reopened. thanks # This fakemail brought to you by your local debbugs # administrator From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 21 18:25:23 2019 Received: (at 29799) by debbugs.gnu.org; 21 Nov 2019 23:25:23 +0000 Received: from localhost ([127.0.0.1]:53547 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iXvpB-0008Jb-36 for submit@debbugs.gnu.org; Thu, 21 Nov 2019 18:25:21 -0500 Received: from mail-qt1-f193.google.com ([209.85.160.193]:44561) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iXvp2-0008J7-2K for 29799@debbugs.gnu.org; Thu, 21 Nov 2019 18:25:20 -0500 Received: by mail-qt1-f193.google.com with SMTP id o11so5673389qtr.11 for <29799@debbugs.gnu.org>; Thu, 21 Nov 2019 15:25:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=lfbPsVNeUztfGlCT5s5jBQyUdP+kH9wwD50CqpmVCYI=; b=DQi694R79xHQzoNIWMSc/LAzrWPr4rSDzmZmAy9KXmedE997ROJHG1W91+cFem951C oZkSdqcCYZMlrS9YNU4Vs7JZ1agcm1mGTSoO4iovrShJ7MQuWQRg2c6/pCeO5JD380ws +J+dGi+vKtvlDhsF8joxzYFKjQNnc31JWf4eIj279RSZJGJZvx3bU8jA1pswft3nMZ2U jQv5vkgrT9fMru4Z8XMZAplmYg62WNtoD5W0/B9FrZoAQbyK7s0mrKEqMvvGNwDrPVJ0 8WLWyAs+FGMkYm6z3snXMPxpvKKu5rxbxA/WmjHTHyD7ogJ4q/+JRYcFjRTY8Z7++HJu CuUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=lfbPsVNeUztfGlCT5s5jBQyUdP+kH9wwD50CqpmVCYI=; b=Yem5jyD1Hty+7tY0pVh3To6rG2alRzOMyWzFdfHxf88vit8I7KZ78HT5ojYP3EL+EP IQn4I4kn1JF/jDdAs140lp874Nsxwcv2NdCybGQksDqQ4TyjIINdljMxDxg7+8OubE5B EYCHripddioE/FeeHUpCQmMZN6EaXnw15cDqEZl6Wt3mtPlyc+QVTLJ/WXfz0Z9NYPgc WiPWzvPVMe0kHh9f5K10sN4HoCOHYWkpEwXdpVyowjgrOLXFP1B5IJHRkEkCrd58BOUa cwf2rMv0hPscSzshoBox+I0rKB4Yez3emo/kMFH0StVuiNqL+rxi1HD3A+yaTVkqO22N z7wA== X-Gm-Message-State: APjAAAUsjAlRepO/ou0YRez3TdnH6Q4K+JN2bq17uIXJ/hYpXHEgI1KW MkNMSKVK8HP3NbQMbsEDV5w= X-Google-Smtp-Source: APXvYqzOamW2hKmr0d112pZLSzDsvTskswOA44c+jt3copZCHoVn5lYkQO0oiK09OyD8pZHdun2TXQ== X-Received: by 2002:ac8:f35:: with SMTP id e50mr11582640qtk.39.1574378706493; Thu, 21 Nov 2019 15:25:06 -0800 (PST) Received: from localhost (pool-100-33-98-8.nycmny.fios.verizon.net. [100.33.98.8]) by smtp.gmail.com with ESMTPSA id w18sm2203196qkb.41.2019.11.21.15.25.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Nov 2019 15:25:05 -0800 (PST) From: dick.r.chiang@gmail.com X-Google-Original-From: 29799@debbugs.gnu.org To: Tino Calancha Subject: Re: bug#29799: 24.5; cl-loop guard clause missing References: <87d138beur.fsf@gmail.com> Date: Thu, 21 Nov 2019 18:25:04 -0500 In-Reply-To: <87d138beur.fsf@gmail.com> (Tino Calancha's message of "Thu, 21 Dec 2017 18:38:20 +0900") Message-ID: <87pnhkke27.fsf@dick> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 29799 Cc: 29799@debbugs.gnu.org, monnier@iro.umontreal.ca, npostavs@gmail.com 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.0 (-) --=-=-= Content-Type: text/plain I noticed the following cases stopped working after commit a036543. ;; should not fail (cl-loop for i from 1 upto 100 and j = 1 then (1+ j) do (cl-assert (= i j) t) until (> j 10)) ;; should return (1 0) (cl-loop with result for x below 3 for y below 2 and z = (progn (push x result) nil) finally return result) --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Refix-conditional-step-clauses-in-cl-loop.patch Content-Description: patch v2 >From a7fb384120c60cb1131c3e8136cc92fddf3c097c Mon Sep 17 00:00:00 2001 From: dickmao Date: Thu, 21 Nov 2019 12:00:17 -0500 Subject: [PATCH] Refix conditional step clauses in cl-loop Readdress (bug#29799), and add more tests. * lisp/emacs-lisp/cl-macs.el (cl--loop-bindings, cl-loop): (cl--push-clause-loop-body, cl--parse-loop-clause): New convenience macro for tracking cl--loop-conditions (bug#29799) * lisp/emacs-lisp/cl-macs.el (cl--loop-bindings, cl--loop-symbol-macs, cl-loop): Add cl--loop-conditions, remove cl--loop-guard-cond. (cl--push-clause-loop-body): Apply clause to both cl--loop-conditions and cl--loop-body (cl--parse-loop-clause): Use cl--push-clause-loop-body. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs-loop-and-assignment): Use docstring. (cl-macs-loop-for-as-arith): Removed expected failure. (cl-macs-loop-conditional-step-clauses): Add some tests. --- lisp/emacs-lisp/cl-macs.el | 96 +++++++++++---------------- test/lisp/emacs-lisp/cl-macs-tests.el | 68 +++++++++++++++++-- 2 files changed, 101 insertions(+), 63 deletions(-) diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 80e218884a..a5ecf33203 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -889,7 +889,7 @@ cl-return-from ;;; The "cl-loop" macro. (defvar cl--loop-args) (defvar cl--loop-accum-var) (defvar cl--loop-accum-vars) -(defvar cl--loop-bindings) (defvar cl--loop-body) +(defvar cl--loop-bindings) (defvar cl--loop-body) (defvar cl--loop-conditions) (defvar cl--loop-finally) (defvar cl--loop-finish-flag) ;Symbol set to nil to exit the loop? (defvar cl--loop-first-flag) @@ -897,7 +897,7 @@ cl--loop-initially (defvar cl--loop-name) (defvar cl--loop-result) (defvar cl--loop-result-explicit) (defvar cl--loop-result-var) (defvar cl--loop-steps) -(defvar cl--loop-symbol-macs) (defvar cl--loop-guard-cond) +(defvar cl--loop-symbol-macs) (defun cl--loop-set-iterator-function (kind iterator) (if cl--loop-iterator-function @@ -966,7 +966,8 @@ cl-loop (cl--loop-accum-var nil) (cl--loop-accum-vars nil) (cl--loop-initially nil) (cl--loop-finally nil) (cl--loop-iterator-function nil) (cl--loop-first-flag nil) - (cl--loop-symbol-macs nil) (cl--loop-guard-cond nil)) + (cl--loop-symbol-macs nil) + (cl--loop-conditions nil)) ;; Here is more or less how those dynbind vars are used after looping ;; over cl--parse-loop-clause: ;; @@ -1001,24 +1002,7 @@ cl-loop (list (or cl--loop-result-explicit cl--loop-result)))) (ands (cl--loop-build-ands (nreverse cl--loop-body))) - (while-body - (nconc - (cadr ands) - (if (or (not cl--loop-guard-cond) (not cl--loop-first-flag)) - (nreverse cl--loop-steps) - ;; Right after update the loop variable ensure that the loop - ;; condition, i.e. (car ands), is still satisfied; otherwise, - ;; set `cl--loop-first-flag' nil and skip the remaining - ;; body forms (#Bug#29799). - ;; - ;; (last cl--loop-steps) updates the loop var - ;; (car (butlast cl--loop-steps)) sets `cl--loop-first-flag' nil - ;; (nreverse (cdr (butlast cl--loop-steps))) are the - ;; remaining body forms. - (append (last cl--loop-steps) - `((and ,(car ands) - ,@(nreverse (cdr (butlast cl--loop-steps))))) - `(,(car (butlast cl--loop-steps))))))) + (while-body (nconc (cadr ands) (nreverse cl--loop-steps))) (body (append (nreverse cl--loop-initially) (list (if cl--loop-iterator-function @@ -1051,6 +1035,12 @@ cl-loop (list `(cl-symbol-macrolet ,cl--loop-symbol-macs ,@body)))) `(cl-block ,cl--loop-name ,@body))))) +(defmacro cl--push-clause-loop-body (clause) + "Apply CLAUSE to both `cl--loop-conditions' and `cl--loop-body'." + `(progn + (push ,clause cl--loop-conditions) + (push ,clause cl--loop-body))) + ;; Below is a complete spec for cl-loop, in several parts that correspond ;; to the syntax given in CLtL2. The specs do more than specify where ;; the forms are; it also specifies, as much as Edebug allows, all the @@ -1201,8 +1191,6 @@ cl-loop ;; (def-edebug-spec loop-d-type-spec ;; (&or (loop-d-type-spec . [&or nil loop-d-type-spec]) cl-type-spec)) - - (defun cl--parse-loop-clause () ; uses loop-* (let ((word (pop cl--loop-args)) (hash-types '(hash-key hash-keys hash-value hash-values)) @@ -1281,11 +1269,11 @@ cl--parse-loop-clause (if end-var (push (list end-var end) loop-for-bindings)) (if step-var (push (list step-var step) loop-for-bindings)) - (if end - (push (list - (if down (if excl '> '>=) (if excl '< '<=)) - var (or end-var end)) - cl--loop-body)) + (when end + (cl--push-clause-loop-body + (list + (if down (if excl '> '>=) (if excl '< '<=)) + var (or end-var end)))) (push (list var (list (if down '- '+) var (or step-var step 1))) loop-for-steps))) @@ -1295,7 +1283,7 @@ cl--parse-loop-clause (temp (if (and on (symbolp var)) var (make-symbol "--cl-var--")))) (push (list temp (pop cl--loop-args)) loop-for-bindings) - (push `(consp ,temp) cl--loop-body) + (cl--push-clause-loop-body `(consp ,temp)) (if (eq word 'in-ref) (push (list var `(car ,temp)) cl--loop-symbol-macs) (or (eq temp var) @@ -1318,24 +1306,19 @@ cl--parse-loop-clause ((eq word '=) (let* ((start (pop cl--loop-args)) (then (if (eq (car cl--loop-args) 'then) - (cl--pop2 cl--loop-args) start))) + (cl--pop2 cl--loop-args) start)) + (first-assign (or cl--loop-first-flag + (setq cl--loop-first-flag + (make-symbol "--cl-var--"))))) (push (list var nil) loop-for-bindings) (if (or ands (eq (car cl--loop-args) 'and)) (progn - (push `(,var - (if ,(or cl--loop-first-flag - (setq cl--loop-first-flag - (make-symbol "--cl-var--"))) - ,start ,var)) - loop-for-sets) - (push (list var then) loop-for-steps)) - (push (list var - (if (eq start then) start - `(if ,(or cl--loop-first-flag - (setq cl--loop-first-flag - (make-symbol "--cl-var--"))) - ,start ,then))) - loop-for-sets)))) + (push `(,var (if ,first-assign ,start ,var)) loop-for-sets) + (push `(,var (if ,(car (cl--loop-build-ands + (nreverse cl--loop-conditions))) + ,then ,var)) + loop-for-steps)) + (push `(,var (if ,first-assign ,start ,then)) loop-for-sets)))) ((memq word '(across across-ref)) (let ((temp-vec (make-symbol "--cl-vec--")) @@ -1344,9 +1327,8 @@ cl--parse-loop-clause (push (list temp-vec (pop cl--loop-args)) loop-for-bindings) (push (list temp-len `(length ,temp-vec)) loop-for-bindings) (push (list temp-idx -1) loop-for-bindings) - (push `(< (setq ,temp-idx (1+ ,temp-idx)) - ,temp-len) - cl--loop-body) + (cl--push-clause-loop-body + `(< (setq ,temp-idx (1+ ,temp-idx)) ,temp-len)) (if (eq word 'across-ref) (push (list var `(aref ,temp-vec ,temp-idx)) cl--loop-symbol-macs) @@ -1376,15 +1358,14 @@ cl--parse-loop-clause loop-for-bindings) (push (list var `(elt ,temp-seq ,temp-idx)) cl--loop-symbol-macs) - (push `(< ,temp-idx ,temp-len) cl--loop-body)) + (cl--push-clause-loop-body `(< ,temp-idx ,temp-len))) ;; Evaluate seq length just if needed, that is, when seq is not a cons. (push (list temp-len (or (consp seq) `(length ,temp-seq))) loop-for-bindings) (push (list var nil) loop-for-bindings) - (push `(and ,temp-seq - (or (consp ,temp-seq) - (< ,temp-idx ,temp-len))) - cl--loop-body) + (cl--push-clause-loop-body `(and ,temp-seq + (or (consp ,temp-seq) + (< ,temp-idx ,temp-len)))) (push (list var `(if (consp ,temp-seq) (pop ,temp-seq) (aref ,temp-seq ,temp-idx))) @@ -1480,9 +1461,8 @@ cl--parse-loop-clause (push (list var '(selected-frame)) loop-for-bindings) (push (list temp nil) loop-for-bindings) - (push `(prog1 (not (eq ,var ,temp)) - (or ,temp (setq ,temp ,var))) - cl--loop-body) + (cl--push-clause-loop-body `(prog1 (not (eq ,var ,temp)) + (or ,temp (setq ,temp ,var)))) (push (list var `(next-frame ,var)) loop-for-steps))) @@ -1503,9 +1483,8 @@ cl--parse-loop-clause (push (list minip `(minibufferp (window-buffer ,var))) loop-for-bindings) (push (list temp nil) loop-for-bindings) - (push `(prog1 (not (eq ,var ,temp)) - (or ,temp (setq ,temp ,var))) - cl--loop-body) + (cl--push-clause-loop-body `(prog1 (not (eq ,var ,temp)) + (or ,temp (setq ,temp ,var)))) (push (list var `(next-window ,var ,minip)) loop-for-steps))) @@ -1529,7 +1508,6 @@ cl--parse-loop-clause t) cl--loop-body)) (when loop-for-steps - (setq cl--loop-guard-cond t) (push (cons (if ands 'cl-psetq 'setq) (apply 'append (nreverse loop-for-steps))) cl--loop-steps)))) diff --git a/test/lisp/emacs-lisp/cl-macs-tests.el b/test/lisp/emacs-lisp/cl-macs-tests.el index 09ce660a2f..8523044714 100644 --- a/test/lisp/emacs-lisp/cl-macs-tests.el +++ b/test/lisp/emacs-lisp/cl-macs-tests.el @@ -30,7 +30,7 @@ ;;; ANSI 6.1.1.7 Destructuring (ert-deftest cl-macs-loop-and-assignment () - ;; Bug#6583 + "Bug#6583" :expected-result :failed (should (equal (cl-loop for numlist in '((1 2 4.0) (5 6 8.3) (8 9 10.4)) for a = (cl-first numlist) @@ -61,7 +61,6 @@ ;;; 6.1.2.1.1 The for-as-arithmetic subclause (ert-deftest cl-macs-loop-for-as-arith () "Test various for-as-arithmetic subclauses." - :expected-result :failed (should (equal (cl-loop for i to 10 by 3 collect i) '(0 3 6 9))) (should (equal (cl-loop for i upto 3 collect i) @@ -74,9 +73,9 @@ '(10 8 6))) (should (equal (cl-loop for i from 10 downto 1 by 3 collect i) '(10 7 4 1))) - (should (equal (cl-loop for i above 0 by 2 downfrom 10 collect i) + (should (equal (cl-loop for i downfrom 10 above 0 by 2 collect i) '(10 8 6 4 2))) - (should (equal (cl-loop for i downto 10 from 15 collect i) + (should (equal (cl-loop for i from 15 downto 10 collect i) '(15 14 13 12 11 10)))) (ert-deftest cl-macs-loop-for-as-arith-order-side-effects () @@ -530,4 +529,65 @@ l) '(1)))) +(ert-deftest cl-macs-loop-conditional-step-clauses () + "These tests failed under the initial fixes in #bug#29799." + (should (cl-loop for i from 1 upto 100 and j = 1 then (1+ j) + if (not (= i j)) + return nil + end + until (> j 10) + finally return t)) + + (should (equal (let* ((size 7) + (arr (make-vector size 0))) + (cl-loop for k below size + for x = (* 2 k) and y = (1+ (elt arr k)) + collect (list k x y))) + '((0 0 1) (1 2 1) (2 4 1) (3 6 1) (4 8 1) (5 10 1) (6 12 1)))) + + (should (equal (cl-loop for x below 3 + for y below 2 and z = 1 + collect x) + '(0 1))) + + (should (equal (cl-loop for x below 3 + and y below 2 + collect x) + '(0 1))) + + ;; this is actually disallowed in clisp, but is semantically consistent + (should (equal (cl-loop with result + for x below 3 + for y = (progn (push x result) x) and z = 1 + append (list x y) into result1 + finally return (append result result1)) + '(2 1 0 0 0 1 1 2 2))) + + (should (equal (cl-loop with result + for x below 3 + for _y = (progn (push x result)) + finally return result) + '(2 1 0))) + + ;; this nonintuitive result is replicated by clisp + (should (equal (cl-loop with result + for x below 3 + and y = (progn (push x result)) + finally return result) + '(2 1 0 0))) + + ;; this nonintuitive result is replicated by clisp + (should (equal (cl-loop with result + for x below 3 + and y = (progn (push x result)) then (progn (push (1+ x) result)) + finally return result) + '(3 2 1 0))) + + (should (cl-loop with result + for x below 3 + for y = (progn (push x result) x) then (progn (push (1+ x) result) (1+ x)) + and z = 1 + collect y into result1 + finally return (equal (nreverse result) result1)))) + ;;; cl-macs-tests.el ends here -- 2.23.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 22 07:55:40 2019 Received: (at 29799) by debbugs.gnu.org; 22 Nov 2019 12:55:40 +0000 Received: from localhost ([127.0.0.1]:53909 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iY8TM-0002rF-3W for submit@debbugs.gnu.org; Fri, 22 Nov 2019 07:55:40 -0500 Received: from quimby.gnus.org ([95.216.78.240]:48488) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iY8TJ-0002r2-V8 for 29799@debbugs.gnu.org; Fri, 22 Nov 2019 07:55:38 -0500 Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=marnie) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iY8T9-00037Z-Kz; Fri, 22 Nov 2019 13:55:30 +0100 From: Lars Ingebrigtsen To: dick.r.chiang@gmail.com Subject: Re: bug#29799: 24.5; cl-loop guard clause missing References: <87d138beur.fsf@gmail.com> <87pnhkke27.fsf@dick> Date: Fri, 22 Nov 2019 13:55:26 +0100 In-Reply-To: <87pnhkke27.fsf@dick> (dick r. chiang's message of "Thu, 21 Nov 2019 18:25:04 -0500") Message-ID: <87h82wrry9.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: dick.r.chiang@gmail.com writes: > I noticed the following cases stopped working after commit a036543. > > ; ; should not fail > (cl-loop for i from 1 upto 100 and j = 1 then (1+ j) > do (cl-assert (= i j) t) > until (> j 10)) > > ;; [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: ingebrigtsen.no] -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 29799 Cc: 29799@debbugs.gnu.org, npostavs@gmail.com, monnier@iro.umontreal.ca, Tino Calancha 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.0 (-) dick.r.chiang@gmail.com writes: > I noticed the following cases stopped working after commit a036543. > > ;; should not fail > (cl-loop for i from 1 upto 100 and j = 1 then (1+ j) > do (cl-assert (= i j) t) > until (> j 10)) > > ;; should return (1 0) > (cl-loop with result > for x below 3 > for y below 2 > and z = (progn (push x result) nil) > finally return result) I applied the patch and ran that test case, and it returned (2 1 0). But shouldn't it return (2 1)? -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 22 08:51:33 2019 Received: (at 29799) by debbugs.gnu.org; 22 Nov 2019 13:51:33 +0000 Received: from localhost ([127.0.0.1]:53985 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iY9LQ-00089t-T2 for submit@debbugs.gnu.org; Fri, 22 Nov 2019 08:51:33 -0500 Received: from mail-qt1-f177.google.com ([209.85.160.177]:43108) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iY9LO-00089f-Iw for 29799@debbugs.gnu.org; Fri, 22 Nov 2019 08:51:31 -0500 Received: by mail-qt1-f177.google.com with SMTP id q8so5213425qtr.10 for <29799@debbugs.gnu.org>; Fri, 22 Nov 2019 05:51:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=wCE7SHcnu/sf+Qx1sMegNX3fZiefCDJjll910JMBrIQ=; b=SJRVVuA8LviyrFzsWum6LMgXj+pnwpLcUkM31pjHwaYAWHyjx49vm9gj4QZxOL+BgW B+GlSv/DJ+d/eqkfzonIW3eKvbUN0r0tJ1s09aIC1uucU6a7FDINg/QKFfnSXrpcnK6v PZLTJ72PDPJnmnKUOKVDfVBSQ0EgnuXqjZZaNnFEogupiTPwXblP8L3DjdkcskNBC90V 28uJRLcHhAVeysVwi4uX2qroa+fLYykN2E7htxmVi7S8zSsQKvplX1DJ41RVZlinJfkl BlZxdX0Nch3cRheBUc4ewCdoaxyr1E1TRPo0Oq9eApMdQMswDGpQnePFV/q68XXHhqBm nzwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=wCE7SHcnu/sf+Qx1sMegNX3fZiefCDJjll910JMBrIQ=; b=duVyb12ylkj7wuv/pNPwiLMcRQ9Y/A8zAufL1uJ25YA3t5AfgT+5hGLDgtWlfYnNHI iZlqMASWAjwijdSJXWbVVBPYCEKxQzkBCbbWn0FF4+M0/eiKveVbdaq3U5FjlhptsVad cmdqHNXMp7Z//U5JaOPrcSTZpXxzqo5zZCJUt4ymiK9aHsFwD/BHqOa+A4Z8rcij2PtF qHHARWLusPzZUaGF9uFJvO9/YbTSlIIlRq3uKvv+8CACxn5oR3qFKv3GmnxqSczjROKP VMFKXpOejhLBSZH4GAiHjPXrEOLNBK9B8vpqQ8kjo+tDTS9I7u8GUTtpHwfBPh0HSOFv aiew== X-Gm-Message-State: APjAAAXspW/vrEQKekidhbMpapJbCp56EKqLhnzinoxzw8S6RBxqnDjH MBY2MqetRq/jrxhubrPVtA0= X-Google-Smtp-Source: APXvYqwhQzFb+0gymBnTzzKo0ysRKkaPU+CyS+UloCMeJkcHvct40xvaSQoJoSGsqcEnZ6RKVYCRsQ== X-Received: by 2002:ac8:2a70:: with SMTP id l45mr14796114qtl.230.1574430685012; Fri, 22 Nov 2019 05:51:25 -0800 (PST) Received: from localhost (pool-100-33-98-8.nycmny.fios.verizon.net. [100.33.98.8]) by smtp.gmail.com with ESMTPSA id f22sm1954194qtc.43.2019.11.22.05.51.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Nov 2019 05:51:24 -0800 (PST) From: dick.r.chiang@gmail.com To: Lars Ingebrigtsen Subject: Re: bug#29799: 24.5; cl-loop guard clause missing References: <87d138beur.fsf@gmail.com> <87pnhkke27.fsf@dick> <87h82wrry9.fsf@gnus.org> Date: Fri, 22 Nov 2019 08:51:23 -0500 In-Reply-To: <87h82wrry9.fsf@gnus.org> (Lars Ingebrigtsen's message of "Fri, 22 Nov 2019 13:55:26 +0100") Message-ID: <87mucorpd0.fsf@dick> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 29799 Cc: 29799@debbugs.gnu.org, npostavs@gmail.com, monnier@iro.umontreal.ca, Tino Calancha 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.0 (-) >>>>> Lars Ingebrigtsen writes: >> ;; should return (1 0) (cl-loop with result for x below 3 for y below 2 and >> z = (progn (push x result) nil) finally return result) > I applied the patch and ran that test case, and it returned > (2 1 0). But shouldn't it return (2 1)? Ah, clisp also returns (2 1 0), so while my initial claim is wrong, I am happy the patch conforms with clisp. My human instinct is to say it should return (1 0), but the simultaneity semantics of "and" are tricky. Under no interpretation, do I see it returning (2 1). iter#1 x is 0, *simultaneously* set y = 0 and result = (0) iter#2 x is 1, *simultaneously* set y = 1 and result = (1 0) iter#3 x is 2, *simultaneously* break out of loop and result = (2 1 0) From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 22 09:53:26 2019 Received: (at 29799) by debbugs.gnu.org; 22 Nov 2019 14:53:26 +0000 Received: from localhost ([127.0.0.1]:54047 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iYAJI-00019L-MG for submit@debbugs.gnu.org; Fri, 22 Nov 2019 09:53:25 -0500 Received: from quimby.gnus.org ([95.216.78.240]:50410) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iYAJG-000196-Bb for 29799@debbugs.gnu.org; Fri, 22 Nov 2019 09:53:23 -0500 Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=marnie) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iYAJ5-00043n-O9; Fri, 22 Nov 2019 15:53:14 +0100 From: Lars Ingebrigtsen To: dick.r.chiang@gmail.com Subject: Re: bug#29799: 24.5; cl-loop guard clause missing References: <87d138beur.fsf@gmail.com> <87pnhkke27.fsf@dick> <87h82wrry9.fsf@gnus.org> <87mucorpd0.fsf@dick> Date: Fri, 22 Nov 2019 15:53:10 +0100 In-Reply-To: <87mucorpd0.fsf@dick> (dick r. chiang's message of "Fri, 22 Nov 2019 08:51:23 -0500") Message-ID: <87d0dkq7xl.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: dick.r.chiang@gmail.com writes: >>> ;; should return (1 0) (cl-loop with result for x below 3 for y below 2 and >>> z = (progn (push x result) nil) finally return result) > >> I applied the patch and ran that test case, and it retur [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: ingebrigtsen.no] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 29799 Cc: 29799@debbugs.gnu.org, Tino Calancha , npostavs@gmail.com, monnier@iro.umontreal.ca 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.0 (-) dick.r.chiang@gmail.com writes: >>> ;; should return (1 0) (cl-loop with result for x below 3 for y below 2 and >>> z = (progn (push x result) nil) finally return result) > >> I applied the patch and ran that test case, and it returned >> (2 1 0). But shouldn't it return (2 1)? > > Ah, clisp also returns (2 1 0), so while my initial claim is wrong, I am happy > the patch conforms with clisp. > > My human instinct is to say it should return (1 0), but the simultaneity > semantics of "and" are tricky. > > Under no interpretation, do I see it returning (2 1). > > iter#1 x is 0, *simultaneously* set y = 0 and result = (0) > iter#2 x is 1, *simultaneously* set y = 1 and result = (1 0) > iter#3 x is 2, *simultaneously* break out of loop and result = (2 1 0) Yes, you're right -- I was somehow thinking that "below 3" meant the same as "from 2 downto 0" instead of what it really means: "upto 2". And that "for ... and" meant that I had never realised. :-) loop is a complicated language. So it all looks correct to me now, and I'm applying your patch. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 22 09:54:35 2019 Received: (at control) by debbugs.gnu.org; 22 Nov 2019 14:54:35 +0000 Received: from localhost ([127.0.0.1]:54051 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iYAKR-0001BF-4Z for submit@debbugs.gnu.org; Fri, 22 Nov 2019 09:54:35 -0500 Received: from quimby.gnus.org ([95.216.78.240]:50428) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iYAKN-0001B0-Pe for control@debbugs.gnu.org; Fri, 22 Nov 2019 09:54:34 -0500 Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=marnie) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iYAKG-000447-7V for control@debbugs.gnu.org; Fri, 22 Nov 2019 15:54:26 +0100 Date: Fri, 22 Nov 2019 15:54:23 +0100 Message-Id: <87blt4q7vk.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #29799 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: tags 29799 fixed close 29799 27.1 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control 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.0 (-) tags 29799 fixed close 29799 27.1 quit From unknown Mon Aug 18 14:21:49 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 21 Dec 2019 12:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator From debbugs-submit-bounces@debbugs.gnu.org Tue May 05 22:02:16 2020 Received: (at control) by debbugs.gnu.org; 6 May 2020 02:02:16 +0000 Received: from localhost ([127.0.0.1]:37995 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jW9O4-0006HK-7d for submit@debbugs.gnu.org; Tue, 05 May 2020 22:02:16 -0400 Received: from mail-qk1-f182.google.com ([209.85.222.182]:37571) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jW9O2-0006H6-AG for control@debbugs.gnu.org; Tue, 05 May 2020 22:02:14 -0400 Received: by mail-qk1-f182.google.com with SMTP id c10so470635qka.4 for ; Tue, 05 May 2020 19:02:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=/zgud1WJ+J9k6V7UtPEELeayb/SSHyHsq/KHGQn9J2s=; b=Ju75icmSSp42IXSiLMG3RAHKLyC9f81MnK1AbUqTaGZEk80YgiFS8eB5A4Pl2CooQc DwClswYQz3FzuGbocFhDawB0g8MzxZuVxvcU0v+KsnT3ha2Pg1M2AtjHXml5NOCKFa0b pHgzms3iIJ8a4FUq3JUpfzZqwNXYoQlkAQ5cKl2GVKFoiukxXW6j1cj1bieTojfNdRmD 0a1QL+o0zg99dt9bMmoinYLCzDbUdLevTZ7PUxSxnEd0tlECQROL/o348QerupgLnogL PHMeS22nJ53UXpeZ6GVaO6tB9SlWTO/8Eju/okUQnDJzdqZ+1uEMsmV5nsdGVu5LiE0v k9eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=/zgud1WJ+J9k6V7UtPEELeayb/SSHyHsq/KHGQn9J2s=; b=Qsez8Yp8F66gOLh8XehBEYxykCHsZg4JIsfbUzzwrYfZNFbHxKujtByh0txegDHhYD MMVz35Xw/9LKgB5suAEZlu95bAy3Chrm1Yc8GgvdrBUR7SCIxzrio0WSWNaJsqAjF3Ng 7d/Zg0dpB8Vu/1STqqMSlKqU0u5PTOITq4JPXJVdp6NvAVacNiAz9AwSS7GyHyhjpS+p Gd1Ogaq826LHxtxsx6ivqHSKDryxYsYscb57mkiWniUJ8PvxEIKv5pxWD71btRCtNbGP nhWvw3MIdzl7tfkh8Tad9vYBlvMGswWiSHJkfx1qM+8oq8J5mU7pVr4iNzXzEU8qkEaU PROQ== X-Gm-Message-State: AGi0PuanmcksDn/5Bnm4wYFQPbFHEJWXSrboWwpuIRAY5UFs4rwb4FW3 wZ2Rtq9YtSaP1cNINfSydJFGF2OK X-Google-Smtp-Source: APiQypKRIjU+geqkXGytQHTBSgAF5qVpAMTxzYlfGjhcNcJmX8aT0YIc+piRUnW+c2m97HMXxTIyUg== X-Received: by 2002:a37:4794:: with SMTP id u142mr6570516qka.331.1588730528487; Tue, 05 May 2020 19:02:08 -0700 (PDT) Received: from minid (cbl-45-2-119-47.yyz.frontiernetworks.ca. [45.2.119.47]) by smtp.gmail.com with ESMTPSA id 67sm597935qkm.68.2020.05.05.19.01.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 May 2020 19:02:07 -0700 (PDT) From: Noam Postavsky To: control@debbugs.gnu.org Subject: control message for bug #29799 Date: Tue, 05 May 2020 22:01:45 -0400 Message-ID: <87ftcdn7na.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control 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.0 (-) unarchive 29799 unarchive 29866 quit From debbugs-submit-bounces@debbugs.gnu.org Tue May 05 22:09:21 2020 Received: (at control) by debbugs.gnu.org; 6 May 2020 02:09:21 +0000 Received: from localhost ([127.0.0.1]:38005 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jW9Uv-0006SA-90 for submit@debbugs.gnu.org; Tue, 05 May 2020 22:09:21 -0400 Received: from mail-qk1-f176.google.com ([209.85.222.176]:33406) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jW9Ut-0006Ru-7n; Tue, 05 May 2020 22:09:19 -0400 Received: by mail-qk1-f176.google.com with SMTP id 23so504466qkf.0; Tue, 05 May 2020 19:09:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version; bh=aT17fXu3LQK09JOqEn8PtPIwIvzHnPbXgDVb9K4EMd4=; b=SGIdRCImlzshfu9oSTIV6vZ9PqWHtPoS6NFw2nmike5lD63/j2/bJK6A3TS0Sq3uKC eVBPGWc3TvqhXGthOMZGSXpLsp+pZHB0//uvQT7a4iY3iZZz0SVqikX6TNzTjY/tocPB cnskDG4V2w+9lAKwdoo2C7M9MhlfnmaSPVQxAV48NhkwZPNiEIn6RWy0mtNE9FaAJDZr H9faUSdNI3JzTmdAjnLB6CeqYQmp6xf4XXdE23F5ePgNpxtiUmdcubYthgh5KbDuhnCX Zu9rzCWs4qPnutzgzPQckf17SaGJ2U6AU9bemJjAxIa/ak7dt/SDF3b0CwgU05JiTyYo 5ggg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=aT17fXu3LQK09JOqEn8PtPIwIvzHnPbXgDVb9K4EMd4=; b=YW3t4U9IYPy0GorfNfNQTiDaVi79cWBys0jqCtpfjF5Bv115qQB/5R0KhYin83gxJg /HiD4GREbYsdVRep0ZJcb8tPyyU1ovig2jO3KybSmjDD2SDXddJ7v4M3RXFt5EMLwxi0 l5Qvh48eyIpJFQaO+UJnCobJGnHVpfVdiGGmVG7gK7/nG58A8BEhj76DWbXMV0TnfATf K/HBkTL9e7UwgCqqb2jF4vDntjk0woBDt5xNi+AquuKs8kpswGplZmTN9/JBQK22U0DM H2sX8OsRHrGmiUzv5JHM0rHTgqkN9/b4Cih8vf14S/TuqVN0W6ptx9JRhumim710CIR+ w00g== X-Gm-Message-State: AGi0PuZfbJeHuEn7ZC517cfWq3oSORmaSXOklqVO0z8dmwtaObwX+c74 +ufCNgDVw+RYXKKE3kzpn2mJjLsl X-Google-Smtp-Source: APiQypJs+UP/VO4wM2xHgi14Y0NOENvy590FJdijglmhTxc2u7ct4NijRpKRtx7ejxvh+cfpBOuHtQ== X-Received: by 2002:a37:de16:: with SMTP id h22mr6236284qkj.195.1588730953629; Tue, 05 May 2020 19:09:13 -0700 (PDT) Received: from minid (cbl-45-2-119-47.yyz.frontiernetworks.ca. [45.2.119.47]) by smtp.gmail.com with ESMTPSA id b42sm302500qta.29.2020.05.05.19.09.05 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 May 2020 19:09:12 -0700 (PDT) From: Noam Postavsky To: 29799-quiet@debbugs.gnu.org Subject: Re: bug#29799: 24.5; cl-loop guard clause missing References: <87d138beur.fsf@gmail.com> Date: Tue, 05 May 2020 22:08:51 -0400 In-Reply-To: <87d138beur.fsf@gmail.com> (Tino Calancha's message of "Thu, 21 Dec 2017 18:38:20 +0900") Message-ID: <87a72ln7bg.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.91 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control 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.0 (-) notfixed 29799 27.1 close 29799 28.1 quit The fix for this bug was delayed due to Bug#40727, so it will not be fixed in 27.1. From unknown Mon Aug 18 14:21:49 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 03 Jun 2020 11:24:09 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator