From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.bugs Subject: bug#39169: 28.0.50; Confusing obsolete variable warnings in eieio-defclass-autoload Date: Tue, 29 Dec 2020 11:59:59 +0100 Message-ID: <87v9ckri6o.fsf@web.de> References: <87tv4txf23.fsf@web.de> <87h7srg3x6.fsf@gnus.org> <87bliy4hkp.fsf@gnus.org> <871rjt5sr3.fsf@web.de> <87h7sow6tp.fsf@gnus.org> <87364886ve.fsf@web.de> <87y2m06rkw.fsf@web.de> <87tuwn7pj8.fsf@web.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19297"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 39169@debbugs.gnu.org, Lars Ingebrigtsen To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 29 12:01:13 2020 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 1kuCka-0004uN-Rs for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 29 Dec 2020 12:01:12 +0100 Original-Received: from localhost ([::1]:38824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kuCkZ-0005R7-P0 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 29 Dec 2020 06:01:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37476) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kuCkQ-0005Qt-0h for bug-gnu-emacs@gnu.org; Tue, 29 Dec 2020 06:01:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54453) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kuCkP-0002GD-Ol for bug-gnu-emacs@gnu.org; Tue, 29 Dec 2020 06:01:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kuCkP-0005sR-Md for bug-gnu-emacs@gnu.org; Tue, 29 Dec 2020 06:01:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Michael Heerdegen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 29 Dec 2020 11:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39169 X-GNU-PR-Package: emacs Original-Received: via spool by 39169-submit@debbugs.gnu.org id=B39169.160923961422486 (code B ref 39169); Tue, 29 Dec 2020 11:01:01 +0000 Original-Received: (at 39169) by debbugs.gnu.org; 29 Dec 2020 11:00:14 +0000 Original-Received: from localhost ([127.0.0.1]:37764 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kuCje-0005qb-0l for submit@debbugs.gnu.org; Tue, 29 Dec 2020 06:00:14 -0500 Original-Received: from mout.web.de ([212.227.17.11]:37473) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kuCjb-0005pE-Fl for 39169@debbugs.gnu.org; Tue, 29 Dec 2020 06:00:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1609239602; bh=AxpWUIFy3muyRNxOxKzWXUMjHuY+jPQDoLptz+JPGyk=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=o2M3a4nUwNFf4rn7BLwqzLs3JDlJQvhyR2mfSFsH2kEhj9nTkzMFCNctSCSCak5ZE mKjuyR+nlIZwrFyGQLWIutNiCJeDGhrMZCe3Bphx8Q5+U3JjDTZOL7dUztexxPxnUx TVEmaUwOR1DrKa2xHvaUweSvp7IGtCQKNwySJ9U4= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Original-Received: from drachen.dragon ([88.67.99.46]) by smtp.web.de (mrweb105 [213.165.67.124]) with ESMTPSA (Nemesis) id 1N5CUp-1jvfgS2NRF-0110U0; Tue, 29 Dec 2020 12:00:01 +0100 In-Reply-To: (Stefan Monnier's message of "Thu, 27 Aug 2020 17:38:45 -0400") X-Provags-ID: V03:K1:yyWpMUS5977F1VHtqzTRc6ZAO3UKnMHqQ0bl08soMF3Yq1Upzbw YuRFI3TmzcObdeGclaccPyjQCxrfMiBLHFS3Mb7VqhRJN0NXD2ndoqPonyYzHN0V0yCJX49 dKdKOEwqDaVdpcIn7jsG3kJWmN1vApgirCsa7lpKKuSegJD5MZ7IqaTnYEvpMwmMQJk66B2 JRMraB5SmNUtbXmOSalug== X-UI-Out-Filterresults: notjunk:1;V03:K0:GZbAN4fwt7I=:p3jsZGN+Yt9RwJx2i9gcNs iUjAt4mAFd/vdm8nd2g/cj2UZfbc4dz81zea9xRIahd7uD9GIIPuHzcDQyd7E2AugqWQH3U2I Zea9TrkIrjS4s+8CQH1pN2J8LS6eEXH+cAcFp76u5+UMxQPJwkNkNgfEnUS7/plojp9CAq2Ne UTeChp/Qxz3Uj3H3sKxyUt7nXHAuWObHFxwlB54PYMXEfk13V66ksnySaSXJJQ3uVq4PgEAI6 Xyv//5vpvfpHoQQg4PzIax87eKjGYPJ7fAo4uy8PNii6BABsZfNEu4Yk9okWYdrDBxsLFQL83 TWOJxKtk/ZXGIHbI1aqbbPMz2CAXDWdvsPrimE1ip3oRWRw60261dHe2rJZ1AeVMvKYAFriO6 JZJz3Af/Tddtq1AQBBR/6O+L1yBukh74nLv6rEMwk7NkNz+Uf+u/1J5B7TJwG+MbmPUCvNjeg o8IVqlWojMaao+QFNJVyCrYSVCsvPsLVo+yjx5MjD8TfQWs6NMiUEvS9jT5JRWq32TSfKNKqO fmYx+q5Xnla8F4oCNrOfySzhixIVVhUVu0twQCMYKNWtfTy5yRlC/6Eb9Jp6OuJg7q+FCbX6A JXZV+nB5Fc4VyFOVNpch9eHxlRjvMskf7arf6pbjIaFdpLrz03kRQhoqg+NzNXY2K3Ye5Cvdr BpTBDfHJINUFhfWDqKDoXv++nP5VPeErKE4lF3algxSfL/PIOAsvdbfV0L/O46yOUIWwmr6z1 v9GFaSsGZO1WvAAr6995Z33HB3YPsR7WyevRhzmI3kBNGAXMmqPZjMmjm4WST15Bk0o36kpS 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:196922 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier writes: > > diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el > > index 966990bac9..418070fabe 100644 > > --- a/lisp/emacs-lisp/bytecomp.el > > +++ b/lisp/emacs-lisp/bytecomp.el > > @@ -3357,6 +3357,7 @@ byte-compile-check-variable > > (and od > > (not (memq var byte-compile-not-obsolete-vars)) > > (not (memq var byte-compile-global-not-obsolete-vars)) > > + (not (memq var byte-compile-lexical-variables)) > > (or (pcase (nth 1 od) > > ('set (not (eq access-type 'reference))) > > ('get (eq access-type 'reference)) > > Yes! Coming back to this now... Ok, then let's do that! > > BTW, while I looked at this, I found this spurious lookup in > > `byte-compile-lexical-variables': > > > > #+begin_src emacs-lisp > > (defun byte-compile-form (form &optional for-effect) > > (let ((byte-compile--for-effect for-effect)) > > (cond > > ((not (consp form))..10..) > > ((symbolp (car form)) > > (let* ((fn (car form))..4..) > > (when (memq fn '(set symbol-value run-hooks..4..) > > (pcase (cdr form) > > (`(',var . ,_) > > (when (assq var byte-compile-lexical-variables) ;; <--- here > > (byte-compile-report-error > > (format-message "%s cannot use lexical var `%s'" fn var))) > > ...))))))))) > > #+end_src > > > > shouldn't the `assq' be `memq'? > > I think you're right. Seems this has been treated meanwhile: Bug#44980 and commit ace6eba036 "Fix byte-compiler warning for failed uses of lexical vars", Stefan Kangas. > Both changes should ideally come with corresponding regression tests. I tried to add an appropriate test for the remaining case, please check the following patch (my first addition to the test suite) - is it what you had in mind? - where I also try to give a less confusing (but longer) compiler warning. Does it look alright? --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Fix-obsolete-variable-warnings-about-class-names.patch Content-Transfer-Encoding: quoted-printable =46rom 63f3420d91273fecb51095c20c81d9fd0508ee4c Mon Sep 17 00:00:00 2001 From: Michael Heerdegen Date: Tue, 22 Dec 2020 05:44:47 +0100 Subject: [PATCH] Fix obsolete variable warnings about class names * lisp/emacs-lisp/eieio-core.el (eieio-defclass-autoload): Try to make the wording of the warning about the obsoleted variable less confusing. * lisp/emacs-lisp/bytecomp.el (byte-compile-check-variable): Don't warn for lexical variables (Bug#39169). Fix spurious `or'. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp/warn-obsolete-variable-bound\.el): New test. * test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-variable-bound.el: New file. =2D-- lisp/emacs-lisp/bytecomp.el | 9 +++++---- lisp/emacs-lisp/eieio-core.el | 3 ++- .../bytecomp-resources/warn-obsolete-variable-bound.el | 7 +++++++ test/lisp/emacs-lisp/bytecomp-tests.el | 3 +++ 4 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-= variable-bound.el diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index f14ad93d2e..aa531c2558 100644 =2D-- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -3441,10 +3441,11 @@ byte-compile-check-variable (and od (not (memq var byte-compile-not-obsolete-vars)) (not (memq var byte-compile-global-not-obsolete-vars)) - (or (pcase (nth 1 od) - ('set (not (eq access-type 'reference))) - ('get (eq access-type 'reference)) - (_ t))))) + (not (memq var byte-compile-lexical-variables)) + (pcase (nth 1 od) + ('set (not (eq access-type 'reference))) + ('get (eq access-type 'reference)) + (_ t)))) (byte-compile-warn-obsolete var)))) (defsubst byte-compile-dynamic-variable-op (base-op var) diff --git a/lisp/emacs-lisp/eieio-core.el b/lisp/emacs-lisp/eieio-core.el index 3bc65d0d4c..010ff54d4d 100644 =2D-- a/lisp/emacs-lisp/eieio-core.el +++ b/lisp/emacs-lisp/eieio-core.el @@ -215,7 +215,8 @@ eieio-defclass-autoload ;; turn this into a usable self-pointing symbol (when eieio-backward-compatibility (set cname cname) - (make-obsolete-variable cname (format "use \\=3D'%s instead" cnam= e) + (make-obsolete-variable cname (format "\ +use \\=3D'%s or turn off `eieio-backward-compatibility' instead" cname) "25.1")) (setf (cl--find-class cname) newc) diff --git a/test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-variabl= e-bound.el b/test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-variabl= e-bound.el new file mode 100644 index 0000000000..e65a541e6e =2D-- /dev/null +++ b/test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-variable-bound= .el @@ -0,0 +1,7 @@ +;;; -*- lexical-binding: t -*- + +(make-obsolete-variable 'bytecomp--tests-obsolete-var-2 nil "99.99") + +(defun foo () + (let ((bytecomp--tests-obsolete-var-2 2)) + bytecomp--tests-obsolete-var-2)) diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp= /bytecomp-tests.el index 47aab563f6..c4a27b9ef8 100644 =2D-- a/test/lisp/emacs-lisp/bytecomp-tests.el +++ b/test/lisp/emacs-lisp/bytecomp-tests.el @@ -625,6 +625,9 @@ "warn-obsolete-variable-same-file.el" (bytecomp--define-warning-file-test "warn-obsolete-variable.el" "bytecomp--tests-obs.*obsolete.*99.99") +(bytecomp--define-warning-file-test "warn-obsolete-variable-bound.el" + "bytecomp--tests-obs.*obsolete.*99.99" t) + (bytecomp--define-warning-file-test "warn-redefine-defun-as-macro.el" "as both function and macro") =2D- 2.29.2 --=-=-= Content-Type: text/plain TIA, Michael. --=-=-=--