diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2023-05-01 15:55:32 +0200 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2023-05-01 17:11:50 +0200 |
commit | 7acb3f1c060872b1802e7548d991ca8a9f0fef01 (patch) | |
tree | 3f40fc40d805a84daac37748ade991485de284c8 /doc | |
parent | aa56253407eaa62fdfbc037d5b5a6b3c41e6796e (diff) | |
download | emacs-7acb3f1c060872b1802e7548d991ca8a9f0fef01.tar.gz |
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.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/lispref/functions.texi | 6 | ||||
-rw-r--r-- | doc/lispref/symbols.texi | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi index 42441361fea..dc0d182d50d 100644 --- a/doc/lispref/functions.texi +++ b/doc/lispref/functions.texi @@ -2631,6 +2631,12 @@ so the byte compiler can ignore calls whose value is ignored. This is the same as the @code{side-effect-free} property of the function's symbol, @pxref{Standard Properties}. +@item (important-return-value @var{val}) +If @var{val} is non-@code{nil}, the byte compiler will warn about +calls to this function that do not use the returned value. This is the +same as the @code{important-return-value} property of the function's +symbol, @pxref{Standard Properties}. + @item (speed @var{n}) Specify the value of @code{native-comp-speed} in effect for native compilation of this function (@pxref{Native-Compilation Variables}). diff --git a/doc/lispref/symbols.texi b/doc/lispref/symbols.texi index c6a0408abd1..34db0caf3a8 100644 --- a/doc/lispref/symbols.texi +++ b/doc/lispref/symbols.texi @@ -643,6 +643,12 @@ ignore a call whose value is unused. If the property's value is calls. In addition to byte compiler optimizations, this property is also used for determining function safety (@pxref{Function Safety}). +@item important-return-value +@cindex @code{important-return-value} property +A non-@code{nil} value makes the byte compiler warn about code that +calls the named function without using its returned value. This is +useful for functions where doing so is likely to be a mistake. + @item undo-inhibit-region If non-@code{nil}, the named function prevents the @code{undo} operation from being restricted to the active region, if @code{undo} is invoked |