From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#73881: 31.0.50; Unexpected warnings about recursive occurrences of obsolete functions Date: Sun, 27 Oct 2024 15:18:51 -0400 Message-ID: References: <86wmi4jh54.fsf@gnu.org> <86jze4j6wh.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38434"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 73881@debbugs.gnu.org, Eli Zaretskii , Andrea Corallo , Eshel Yaron To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Oct 27 20:19:42 2024 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 1t58nd-0009sO-E1 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 27 Oct 2024 20:19:41 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t58nQ-0002gJ-Er; Sun, 27 Oct 2024 15:19:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t58nP-0002g1-2N for bug-gnu-emacs@gnu.org; Sun, 27 Oct 2024 15:19:27 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t58nO-0005mm-Py for bug-gnu-emacs@gnu.org; Sun, 27 Oct 2024 15:19:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=JwVLhmjOdgeSTkXBKh8r2Dv/+RRWyIrII6wAB8SoFXA=; b=fXJKpOwx7pPf0a3LBXz+hXHIlA/cLwujpTqL+r9lg/hSEojbEOy0wB43I9Dx9hkGCJxME7AFjjh+XFSxRm0HhgWXLiorkKJVK4TOiT9/9lkf3WnEKBFlYExz/WRx1dOQlk51uSZf4YwbFDgmke2XWJjyJUlFhLGof4T555WP68B49XBGk9hpDJtJsTWCYnh66NfUsIown2vdBsLNTv66LQ+3ZizPM4IgCiUkQOVpHFjeQqrx4BvuMwPO1VO0fQRk8bmmJGigu23/O4ujI7voSbkOQPl6uCFt9p4J91H0y8XOqPzUofrNOzlXfZ/Moyndg1MJ1/Z9OvVZqzp7bKPlig==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t58nx-0006Fa-QK for bug-gnu-emacs@gnu.org; Sun, 27 Oct 2024 15:20:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 Oct 2024 19:20:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73881 X-GNU-PR-Package: emacs Original-Received: via spool by 73881-submit@debbugs.gnu.org id=B73881.173005677723977 (code B ref 73881); Sun, 27 Oct 2024 19:20:01 +0000 Original-Received: (at 73881) by debbugs.gnu.org; 27 Oct 2024 19:19:37 +0000 Original-Received: from localhost ([127.0.0.1]:46389 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t58nY-0006Ef-QF for submit@debbugs.gnu.org; Sun, 27 Oct 2024 15:19:37 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:43838) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t58nW-0006EP-5h for 73881@debbugs.gnu.org; Sun, 27 Oct 2024 15:19:34 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 3A016100180; Sun, 27 Oct 2024 15:18:53 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1730056732; bh=t5yJUEI4nuoJuwwW6jci2MBlyT1i7od8K9SGdsTpl1A=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=lZXb+fgFWKRznxoW3wawAwN9SzEf436eb1JYCX5AkfQ5mHa4zbeymltNyzDjolsxx gnUmOZamio8EDoHURMqehXXB3hmBfnVX1rFCwPnEWHHDiy9UM03nEGiQfBbrHRZioN jvpLO61QwRPeOEuVolVYAP0ucNTc0IxEoryyAQ1+JCdUd6V0O6zxyF7TeX7Y3jUktI RW2rqU9ndIITd3TnfIioBsY797XkyBsO7lSTE9ViExqVB8s4uwh5z9Pjk6S2xwY8l/ EzoIy9bNsrPL5n3r6Gs9LYGvP4xXrp+v+ofM3nceu6VOA5Q58vmXD0fgbJO3ftoE58 QMoEGeX3i+vQg== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 5D21A100043; Sun, 27 Oct 2024 15:18:52 -0400 (EDT) Original-Received: from pastel (69-196-161-60.dsl.teksavvy.com [69.196.161.60]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 228A512013C; Sun, 27 Oct 2024 15:18:52 -0400 (EDT) In-Reply-To: (Stefan Kangas's message of "Sun, 20 Oct 2024 04:51:53 -0700") 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:294386 Archived-At: >> ..Hmm.. I think I see the problem: the code I wrote was for variables >> rather than for functions: >> >> ;; If foo.el declares `toto' as obsolete, it is likely that foo.el will >> ;; actually use `toto' in order for this obsolete variable to still work >> ;; correctly, so paradoxically, while byte-compiling foo.el, the presence >> ;; of a make-obsolete-variable call for `toto' is an indication that `toto' >> ;; should not trigger obsolete-warnings in foo.el. >> (byte-defop-compiler-1 make-obsolete-variable) >> (defun byte-compile-make-obsolete-variable (form) >> (when (eq 'quote (car-safe (nth 1 form))) >> (push (nth 1 (nth 1 form)) byte-compile-global-not-obsolete-vars)) >> (byte-compile-normal-call form)) >> >> So maybe we should just do the same for `make-obsolete`? > > I think that makes sense. I propose the patch below (which also fixes a leak of `byte-compile-global-not-obsolete-vars` to code compiled from other files). But I don't think it fixes the OP's problem because (macroexpand '(defun my-foo () (declare (obsolete "blabla" "25")) 42)) => (prog1 (defalias 'my-foo #'(lambda nil ...)) (make-obsolete 'my-foo '"blabla" "25")) IOW, the `make-obsolete` comes *after* the function and thus my new code will only silence warnings for calls to `my-foo` that are present *after* the function definition. Stefan diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index f058fc48cc7..efa1ea6b676 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -433,8 +433,6 @@ byte-compile-interactive-only-functions (defvar byte-compile-not-obsolete-vars nil "List of variables that shouldn't be reported as obsolete.") -(defvar byte-compile-global-not-obsolete-vars nil - "Global list of variables that shouldn't be reported as obsolete.") (defvar byte-compile-not-obsolete-funcs nil "List of functions that shouldn't be reported as obsolete.") @@ -1909,6 +1907,8 @@ byte-compile-close-variables (byte-compile-const-variables nil) (byte-compile-free-references nil) (byte-compile-free-assignments nil) + (byte-compile-not-obsolete-vars nil) + (byte-compile-not-obsolete-funcs nil) ;; ;; Close over these variables so that `byte-compiler-options' ;; can change them on a per-file basis. @@ -2764,6 +2764,8 @@ byte-compile-file-form-with-suppressed-warnings ;; Automatically evaluate define-obsolete-function-alias etc at top-level. (put 'make-obsolete 'byte-hunk-handler 'byte-compile-file-form-make-obsolete) (defun byte-compile-file-form-make-obsolete (form) + (when (eq 'quote (car-safe (nth 1 form))) + (push (nth 1 (nth 1 form)) byte-compile-not-obsolete-funcs)) (prog1 (byte-compile-keep-pending form) (apply 'make-obsolete (mapcar 'eval (cdr form))))) @@ -3808,7 +3810,6 @@ byte-compile-check-variable ((let ((od (get var 'byte-obsolete-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)) (pcase (nth 1 od) ('set (not (eq access-type 'reference))) @@ -5068,7 +5069,7 @@ lambda (byte-defop-compiler-1 make-obsolete-variable) (defun byte-compile-make-obsolete-variable (form) (when (eq 'quote (car-safe (nth 1 form))) - (push (nth 1 (nth 1 form)) byte-compile-global-not-obsolete-vars)) + (push (nth 1 (nth 1 form)) byte-compile-not-obsolete-vars)) (byte-compile-normal-call form)) (defun byte-compile-defvar (form &optional toplevel)