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#26486: 25.1.91; unused var warning from cconv.el can't be suppressed Date: Mon, 05 Jul 2021 17:17:06 +0200 Message-ID: <87mtr0x025.fsf_-_@gnus.org> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8156"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 26486@debbugs.gnu.org, John Williams , Stefan Monnier To: Noam Postavsky Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jul 05 17:18:13 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 1m0QMP-00020v-56 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 05 Jul 2021 17:18:13 +0200 Original-Received: from localhost ([::1]:36592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0QMO-0004ul-61 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 05 Jul 2021 11:18:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0QME-0004tT-PV for bug-gnu-emacs@gnu.org; Mon, 05 Jul 2021 11:18:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:34902) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m0QME-0001gs-IU for bug-gnu-emacs@gnu.org; Mon, 05 Jul 2021 11:18:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m0QME-0003qg-Fe for bug-gnu-emacs@gnu.org; Mon, 05 Jul 2021 11:18:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 05 Jul 2021 15:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 26486 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 26486-submit@debbugs.gnu.org id=B26486.162549825414723 (code B ref 26486); Mon, 05 Jul 2021 15:18:02 +0000 Original-Received: (at 26486) by debbugs.gnu.org; 5 Jul 2021 15:17:34 +0000 Original-Received: from localhost ([127.0.0.1]:46436 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m0QLZ-0003ox-2Z for submit@debbugs.gnu.org; Mon, 05 Jul 2021 11:17:33 -0400 Original-Received: from quimby.gnus.org ([95.216.78.240]:58546) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m0QLX-0003of-AF for 26486@debbugs.gnu.org; Mon, 05 Jul 2021 11:17:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: 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=YzEN0yZ5xVLwfid0prmiCU97RR6WeakZOMO0T+OEnEs=; b=stlphW9bHn+D5TK99wF/5BRLNB S81zFOcGIC1Ivul6eMbWPTxLmWvhaZHVi8Ae/YGyWZzi9Lv6X3fdTIyFgiWX0h3QAr3mbJAILMtsL FG3s1k1XjycRvUJ9Au2PKylypcjVXjJ/cE7BAQ2mk3jF0/w/N5ilzjf1KIkzGAVX1tmg=; Original-Received: from cm-84.212.220.105.getinternet.no ([84.212.220.105] helo=elva) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m0QLM-0005oe-RY; Mon, 05 Jul 2021 17:17:11 +0200 X-Now-Playing: Tuxedomoon's _Live in Umbria (1989)_: "Nervous Guy" In-Reply-To: (Noam Postavsky's message of "Thu, 13 Apr 2017 15:28:21 -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:209469 Archived-At: Noam Postavsky writes: > This happens also without a macro. > > ;; -*- lexical-binding: t; byte-compile-warnings: nil -*- > (with-no-warnings (let (unused))) This currently gives a warning about both an unused variable and an empty let body. The following seemingly straightforward patch fixes both these things, I'd appreciate it if somebody had a look over it first, though. :-) (So Stefan M added to the CCs.) diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 70999648d4..d97bc1073b 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -325,6 +325,7 @@ byte-compile-warnings docstrings docstrings that are too wide (longer than 80 characters, or `fill-column', whichever is bigger) suspicious constructs that usually don't do what the coder wanted. + empty-body the body of a binding form is empty. If the list begins with `not', then the remaining elements specify warnings to suppress. For example, (not mapcar) will suppress warnings about mapcar." diff --git a/lisp/emacs-lisp/cconv.el b/lisp/emacs-lisp/cconv.el index f663710902..f1579cda8b 100644 --- a/lisp/emacs-lisp/cconv.el +++ b/lisp/emacs-lisp/cconv.el @@ -259,7 +259,8 @@ cconv--warn-unused-msg (not (intern-soft var)) (eq ?_ (aref (symbol-name var) 0)) ;; As a special exception, ignore "ignore". - (eq var 'ignored)) + (eq var 'ignored) + (not (byte-compile-warning-enabled-p 'unbound var))) (let ((suggestions (help-uni-confusable-suggestions (symbol-name var)))) (format "Unused lexical %s `%S'%s" varkind var diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el index df864464b7..e9c2eb3fee 100644 --- a/lisp/emacs-lisp/macroexp.el +++ b/lisp/emacs-lisp/macroexp.el @@ -319,14 +319,16 @@ macroexp--expand-all (`(,(and fun (or 'let 'let*)) . ,(or `(,bindings . ,body) pcase--dontcare)) (macroexp--cons fun - (macroexp--cons (macroexp--all-clauses bindings 1) - (if (null body) - (macroexp-unprogn - (macroexp-warn-and-return - (format "Empty %s body" fun) - nil t)) - (macroexp--all-forms body)) - (cdr form)) + (macroexp--cons + (macroexp--all-clauses bindings 1) + (if (null body) + (macroexp-unprogn + (macroexp-warn-and-return + (and (byte-compile-warning-enabled-p 'empty-body) + (format "Empty %s body" fun)) + nil t)) + (macroexp--all-forms body)) + (cdr form)) form)) (`(,(and fun `(lambda . ,_)) . ,args) ;; Embedded lambda in function position. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no