From 7acb3f1c060872b1802e7548d991ca8a9f0fef01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= Date: Mon, 1 May 2023 15:55:32 +0200 Subject: Add the function declaration and property `important-return-value` Now the declaration (declare (important-return-value t)) can be used to have the byte-compiler warn when the return value from a call is discarded (bug#61730). * lisp/emacs-lisp/bytecomp.el (byte-compile-form) (important-return-value-fns): Use the function property `important-return-value` instead of looking through a static list. * lisp/emacs-lisp/byte-run.el (byte-run--set-important-return-value) (defun-declarations-alist): New function declaration, setting the property of the same name. * lisp/emacs-lisp/cl-macs.el: * lisp/subr.el (assoc-default): Set the property. * doc/lispref/functions.texi (Declare Form): * doc/lispref/symbols.texi (Standard Properties): Document. * etc/NEWS: Announce. --- lisp/subr.el | 1 + 1 file changed, 1 insertion(+) (limited to 'lisp/subr.el') diff --git a/lisp/subr.el b/lisp/subr.el index 427014cedc3..1452a1117d3 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -862,6 +862,7 @@ If that is non-nil, the element matches; then `assoc-default' If no element matches, the value is nil. If TEST is omitted or nil, `equal' is used." + (declare (important-return-value t)) (let (found (tail alist) value) (while (and tail (not found)) (let ((elt (car tail))) -- cgit v1.2.1