summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/bytecomp.el
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2007-09-21 04:24:18 +0000
committerGlenn Morris <rgm@gnu.org>2007-09-21 04:24:18 +0000
commitea2a4394d7149f8b6c93baac1cc8e2f5a58bd845 (patch)
tree497873bcd832324c25312b37681f30c6c87d2295 /lisp/emacs-lisp/bytecomp.el
parent2baf2ff9f003676f4db77683b2c86a89084259b8 (diff)
downloademacs-ea2a4394d7149f8b6c93baac1cc8e2f5a58bd845.tar.gz
Markus Triska <markus.triska at gmx.at>
(byte-compile-normal-call): Warn when `mapcar' is called for effect.
Diffstat (limited to 'lisp/emacs-lisp/bytecomp.el')
-rw-r--r--lisp/emacs-lisp/bytecomp.el4
1 files changed, 4 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 2c14bb66609..10b65d4c47e 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -2831,6 +2831,10 @@ That command is designed for interactive use only" fn))
(defun byte-compile-normal-call (form)
(if byte-compile-generate-call-tree
(byte-compile-annotate-call-tree form))
+ (when (and for-effect (eq (car form) 'mapcar))
+ (byte-compile-set-symbol-position 'mapcar)
+ (byte-compile-warn
+ "`mapcar' called for effect; use `mapc' or `dolist' instead"))
(byte-compile-push-constant (car form))
(mapc 'byte-compile-form (cdr form)) ; wasteful, but faster.
(byte-compile-out 'byte-call (length (cdr form))))