diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2023-04-09 15:57:31 +0200 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2023-04-09 18:23:05 +0200 |
commit | 6157e3e4bc7e4e097e02c572379d1b1542e1d716 (patch) | |
tree | eccda38427b4e8e7d2a42f2211f3f59d2a9331d0 /etc | |
parent | 4f0849a9e6d29e25d23e061bd81bacce9468856d (diff) | |
download | emacs-6157e3e4bc7e4e097e02c572379d1b1542e1d716.tar.gz |
Extend ignored-return-value warning to more functions (bug#61730)
Warn when the return value of certain functions is unused. Previously
this was only done for side-effect-free functions, and for `mapcar`.
These are functions where the return value is important for correct
usage or where ignoring it is likely to indicate a mistake. The exact
set of functions is tentative and will be modified as we gain a better
understanding of which ones to include.
The current set comprises higher order functions such as `mapcar`
which are not primarily called for the effects of their function
arguments, and list-mutating functions like `nreverse` whose return
value is essential.
* lisp/emacs-lisp/bytecomp.el (byte-compile-form): Add list of
functions to warn about when their value is ignored.
* etc/NEWS: Announce.
Diffstat (limited to 'etc')
-rw-r--r-- | etc/NEWS | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -443,6 +443,21 @@ simplified away. This warning can be suppressed using 'with-suppressed-warnings' with the warning name 'suspicious'. +--- +*** Warn about more ignored function return values. +The compiler now warns when the return value from certain functions is +ignored. Example: + + (progn (nreverse my-list) my-list) + +will elicit a warning because it is usually pointless to call +'nreverse' on a list without using the returned value. To silence the +warning, make use of the value in some way, such as assigning it to a +variable. You can also wrap the function call in '(ignore ...)'. + +This warning can be suppressed using 'with-suppressed-warnings' with +the warning name 'ignored-return-value'. + +++ ** New function 'file-user-uid'. This function is like 'user-uid', but is aware of file name handlers, |