From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#31641: 26.1; iter-do variable not left unused warning Date: Thu, 04 Feb 2021 11:05:24 +0100 Message-ID: <87czxgtafv.fsf@gnus.org> References: <20180529131230.kijx2bkcvcqsyhgg@nullprogram.com> <87in76cdpd.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32957"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Christopher Wellons , 31641@debbugs.gnu.org, Stefan Monnier To: Noam Postavsky Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Feb 04 11:34:05 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l7bxb-0008Qr-IP for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 04 Feb 2021 11:34:03 +0100 Original-Received: from localhost ([::1]:44008 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7bxa-0007q6-C1 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 04 Feb 2021 05:34:02 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53774) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7bWU-0002a0-GP for bug-gnu-emacs@gnu.org; Thu, 04 Feb 2021 05:06:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:56457) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l7bWU-0003aC-7g for bug-gnu-emacs@gnu.org; Thu, 04 Feb 2021 05:06:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l7bWU-0005zz-1l for bug-gnu-emacs@gnu.org; Thu, 04 Feb 2021 05:06:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 04 Feb 2021 10:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31641 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 31641-submit@debbugs.gnu.org id=B31641.161243314323031 (code B ref 31641); Thu, 04 Feb 2021 10:06:02 +0000 Original-Received: (at 31641) by debbugs.gnu.org; 4 Feb 2021 10:05:43 +0000 Original-Received: from localhost ([127.0.0.1]:39768 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7bWB-0005zP-5G for submit@debbugs.gnu.org; Thu, 04 Feb 2021 05:05:43 -0500 Original-Received: from quimby.gnus.org ([95.216.78.240]:55416) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7bW9-0005yy-AU for 31641@debbugs.gnu.org; Thu, 04 Feb 2021 05:05:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=sav7jVW1axezH4YiPbegBCBtg1C7TwAjYbnBx4EGqX0=; b=hR/vy8BOPWcsjsFKUGgG3VzZUS 6YfgCRuWWM4pRCxTDELN8wpMglXcYcz3hehHWB12k5dfD+qmRLOpwBfWYcD+WYrav/GQsm9By1dKf 8cCe+3JZUloyTxBq6BlIZ6ni7XPwFRX0fsY0vSt4lrmvE9GccseoPivCp8AIzqaW/qIY=; Original-Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l7bVu-0005Vn-AL; Thu, 04 Feb 2021 11:05:29 +0100 X-Now-Playing: Drew McDowall's _Rogue Pulse: Gravity Collapse (9)_: "Interstitial" In-Reply-To: <87in76cdpd.fsf@gmail.com> (Noam Postavsky's message of "Tue, 29 May 2018 18:13:50 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:199283 Archived-At: Noam Postavsky writes: >> When byte-compiling an iter-do form with a variable intended to be >> left unused, the compiler emits a false warning: >> >> ;;; -*- lexical-binding: t; -*- >> (require 'generator) >> (iter-do (_ i)) >> ;; -> "Warning: variable =E2=80=98_=E2=80=99 not left unused" > > Looking at the expansion, I guess the setf should be dropped if the > variable name starts with _. > > (let (_ > #3=3D#:iter-do-result11 > (#1=3D#:iter-do-iterator-done8 nil) > (#2=3D#:iter-do-iterator10 i)) > (while (not #1#) > (condition-case #4=3D#:iter-do-condition9 > (setf _ (iter-next #2#)) > (iter-end-of-sequence > (setf #3# (cdr #4#)) > (setf #1# t))) > (unless #1#)) > #3#) The following patch does this, but I'm not sure whether this is correct or not -- in other cases, the _ convention just removes the warning, but doesn't change the semantics. I wondered whether we could just suppress this warning like this: ,(if (string-match-p "\\`_" (symbol-name var)) `(with-suppressed-warnings ((not-unused ,var)) (setf ,var (iter-next ,it-symbol))) `(setf ,var (iter-next ,it-symbol))) But no, cconv--analyze-use is called too early, and would have to be taught about `with-suppressed-warnings'... which, looking at the code, isn't immediately obvious how to do. So does anybody have any ideas here? diff --git a/lisp/emacs-lisp/generator.el b/lisp/emacs-lisp/generator.el index 9eb6d95964..0b644cc72c 100644 --- a/lisp/emacs-lisp/generator.el +++ b/lisp/emacs-lisp/generator.el @@ -731,7 +731,10 @@ iter-do (,it-symbol ,iterator)) (while (not ,done-symbol) (condition-case ,condition-symbol - (setf ,var (iter-next ,it-symbol)) + ;; Variables that start with an underscore shouldn't be set. + ,(if (string-match-p "\\`_" (symbol-name var)) + nil + `(setf ,var (iter-next ,it-symbol))) (iter-end-of-sequence (setf ,result-symbol (cdr ,condition-symbol)) (setf ,done-symbol t))) --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no