GNU bug report logs -
#61730
30.0.50; Compiler warnings for delq and delete
Previous Next
Full log
Message #11 received at 61730 <at> debbugs.gnu.org (full text, mbox):
> I think we should add compiler warnings
You rang?
> for `delete' and `delq' function
> calls whose return values are unused.
Let's experiment: warning about for-effect calls to
mapcar mapcan mapconcat
delq delete delete-dups delete-consecutive-dups
cl-delete cl-delete-if cl-delete-if-not cl-delete-duplicates
sort
results in 34 such calls found on master, most of them about `delq` and `delete`, but `delete-dups`, `cl-delete`, `mapconcat` and `sort` are also represented.
Some of these are no doubt safe, a few of them knowingly so, but it's definitely not obvious from a quick look at the code. It's poor style in any case.
Thus such a warning definitely falls on the beneficial side. Let's do it.
> I think the warnings could be added in a similar way as the "mapcar
> called for effect" warnings work.
That's probably the best place to start (although we prefer warnings to be emitted by the front-end and not in codegen).
We may want to change the warning text from "called for effect" because it's written from the perspective of the compiler; the programmer thinks of it as 'not using the return value'.
For that matter, `with-suppressed-warnings` doesn't work for suppressing this warning very well; we may want to do something about that. This is true for the existing `mapcar` warning as well.
> Adding the same kind of warning for `remq' and `remove' would probably
> also be useful. This will probably not occur that often but it still
> would be useful I think.
The compiler should already warn about those two since they are declared side-effect-free. Unless somehow `byte-compile-delete-errors` is set during compilation, which can happen if the code messes about with (optimise (safety ...)) -- it's a bit unfortunate. Please tell us if you observe anomalies in this regard.
This bug report was last modified 1 year and 285 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.