From 89c91fdb5982cc5233ad6181dd5b845813ae8eee Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Fri, 21 Sep 2007 04:24:53 +0000 Subject: [PATCH] Markus Triska (byte-compile-normal-call): Warn when `mapcar' is called for effect. --- lisp/ChangeLog | 5 +++++ lisp/emacs-lisp/bytecomp.el | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0fdd025d0be..f238531667a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2007-09-21 Markus Triska + + * emacs-lisp/bytecomp.el (byte-compile-normal-call): Warn when + `mapcar' is called for effect. + 2007-09-21 Glenn Morris * obsolete/sun-fns.el (emacs-quit-menu): Remove emacstool-related code. 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)))) -- 2.39.5