From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#29799: 24.5; cl-loop guard clause missing Date: Mon, 01 Jan 2018 16:46:30 -0500 Message-ID: <874lo5tfpl.fsf@users.sourceforge.net> References: <87d138beur.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1514843116 17188 195.159.176.226 (1 Jan 2018 21:45:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 1 Jan 2018 21:45:16 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux) Cc: 29799@debbugs.gnu.org, monnier@iro.umontreal.ca To: Tino Calancha Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jan 01 22:45:11 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 1eW7tM-0003xn-5r for geb-bug-gnu-emacs@m.gmane.org; Mon, 01 Jan 2018 22:45:08 +0100 Original-Received: from localhost ([::1]:44837 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eW7vL-0005HM-E4 for geb-bug-gnu-emacs@m.gmane.org; Mon, 01 Jan 2018 16:47:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eW7vF-0005H5-El for bug-gnu-emacs@gnu.org; Mon, 01 Jan 2018 16:47:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eW7vC-00055J-CD for bug-gnu-emacs@gnu.org; Mon, 01 Jan 2018 16:47:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:51567) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eW7vC-000557-9l for bug-gnu-emacs@gnu.org; Mon, 01 Jan 2018 16:47:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eW7vB-0005AA-Rh for bug-gnu-emacs@gnu.org; Mon, 01 Jan 2018 16:47:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 01 Jan 2018 21:47:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29799 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 29799-submit@debbugs.gnu.org id=B29799.151484320019820 (code B ref 29799); Mon, 01 Jan 2018 21:47:01 +0000 Original-Received: (at 29799) by debbugs.gnu.org; 1 Jan 2018 21:46:40 +0000 Original-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 Original-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 Original-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) Original-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) In-Reply-To: <87d138beur.fsf@gmail.com> (Tino Calancha's message of "Thu, 21 Dec 2017 18:38:20 +0900") 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:141701 Archived-At: 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