From 5f38dcd43d75bcc71a9d94713aa4bfb99abee61b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mattias=20Engdeg=C3=A5rd?= Date: Fri, 24 Feb 2023 15:32:04 +0100 Subject: [PATCH] More accurate suppression of ignored return value warning * lisp/emacs-lisp/bytecomp.el (byte-compile-file-form-defalias): Be careful to propagate the for-effect mode through a `with-suppressed-warnings` form when compiling, so that a form inside isn't erroneously considered to have its value 'used' by the surrounding warning suppression form itself. --- lisp/emacs-lisp/bytecomp.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index b0c9667dc19..095468ad978 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -5079,7 +5079,10 @@ binding slots have been popped." (defun byte-compile-suppressed-warnings (form) (let ((byte-compile--suppressed-warnings (append (cadadr form) byte-compile--suppressed-warnings))) - (byte-compile-form (macroexp-progn (cddr form))))) + ;; Propagate the for-effect mode explicitly so that warnings about + ;; ignored return values can be detected and suppressed correctly. + (byte-compile-form (macroexp-progn (cddr form)) byte-compile--for-effect) + (setq byte-compile--for-effect nil))) ;; Warn about misuses of make-variable-buffer-local. (byte-defop-compiler-1 make-variable-buffer-local -- 2.39.5