From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Glenn Morris <rgm@gnu.org>
Cc: 30635@debbugs.gnu.org
Subject: bug#30635: No compiler warning if code forgets to require cl-lib
Date: Mon, 19 Mar 2018 15:58:48 -0400 [thread overview]
Message-ID: <jwv8tanltxq.fsf-monnier+bug#30635@gnu.org> (raw)
In-Reply-To: <bolgfe8e56.fsf@fencepost.gnu.org> (Glenn Morris's message of "Tue, 27 Feb 2018 13:45:57 -0500")
> There's no compiler warning if a library uses cl-lib without requiring it.
> I assume this is because bytecomp.el requires cl-lib.
Should we apply the patch below?
Stefan
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index b3ea9300b0..e75403d80d 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -124,17 +124,11 @@
(require 'backquote)
(require 'macroexp)
(require 'cconv)
-(require 'cl-lib)
-
-;; During bootstrap, cl-loaddefs.el is not created yet, so loading cl-lib
-;; doesn't setup autoloads for things like cl-every, which is why we have to
-;; require cl-extra as well (bug#18804).
-(or (fboundp 'cl-every)
- (require 'cl-extra))
-
-(or (fboundp 'defsubst)
- ;; This really ought to be loaded already!
- (load "byte-run"))
+(eval-when-compile
+ ;; We should refrain from loading cl-lib at run-time within the compiler
+ ;; code, otherwise we can't detect if a file forgets to (require 'cl-lib),
+ ;; as mentioned in bug#30635.
+ (require 'cl-lib))
;; The feature of compiling in a specific target Emacs version
;; has been turned off because compile time options are a bad idea.
@@ -3582,7 +3576,10 @@ byte-compile-and-folded
(cond
((< l 3) (byte-compile-form `(progn ,(nth 1 form) t)))
((= l 3) (byte-compile-two-args form))
- ((cl-every #'macroexp-copyable-p (nthcdr 2 form))
+ ;; This used to use `cl-every' but we need to avoid cl-lib at run-time as
+ ;; mentioned at the beginning of this file.
+ ((null (delq nil (mapcar (lambda (e) (not (macroexp-copyable-p e)))
+ (nthcdr 2 form))))
(byte-compile-form `(and (,(car form) ,(nth 1 form) ,(nth 2 form))
(,(car form) ,@(nthcdr 2 form)))))
(t (byte-compile-normal-call form)))))
next prev parent reply other threads:[~2018-03-19 19:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-27 18:45 bug#30635: No compiler warning if code forgets to require cl-lib Glenn Morris
2018-03-19 19:58 ` Stefan Monnier [this message]
2018-03-19 20:12 ` Glenn Morris
2018-03-22 21:53 ` Stefan Monnier
2018-03-22 22:19 ` Stefan Monnier
2018-03-23 0:56 ` Glenn Morris
2018-03-26 0:51 ` Basil L. Contovounesios
2018-03-26 1:30 ` Basil L. Contovounesios
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='jwv8tanltxq.fsf-monnier+bug#30635@gnu.org' \
--to=monnier@iro.umontreal.ca \
--cc=30635@debbugs.gnu.org \
--cc=rgm@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.