* pacifying "might not be defined at runtime" warning
@ 2016-05-09 6:45 Paul Eggert
2016-05-09 12:20 ` Stefan Monnier
0 siblings, 1 reply; 7+ messages in thread
From: Paul Eggert @ 2016-05-09 6:45 UTC (permalink / raw)
To: Emacs Development
[-- Attachment #1: Type: text/plain, Size: 347 bytes --]
"cd lisp; make compile-always" generates several "might not be defined at
runtime" warnings in the master branch. For example, it generates the attached
warnings in lisp/vc. Is there some reason we shouldn't add directives like
(require 'vc) to pacify the byte compiler here? (See the 2nd attachment.)
Similarly for other warnings like this.
[-- Attachment #2: vc-warnings.txt --]
[-- Type: text/plain, Size: 852 bytes --]
ELC vc/vc-bzr.elc
In end of data:
vc/vc-bzr.el:1336:1:Warning: the function ‘vc-deduce-fileset’ might not be
defined at runtime.
ELC vc/vc-cvs.elc
In end of data:
vc/vc-cvs.el:1319:1:Warning: the following functions might not be defined at
runtime: vc-read-revision, vc-branch-p, vc-expand-dirs, vc-checkout
ELC vc/vc-hg.elc
In end of data:
vc/vc-hg.el:1400:1:Warning: the function ‘vc-compilation-mode’ might not be
defined at runtime.
ELC vc/vc-rcs.elc
In end of data:
vc/vc-rcs.el:1446:1:Warning: the following functions might not be defined at
runtime: vc-read-revision, vc-branch-p, vc-buffer-context,
vc-restore-buffer-context, vc-setup-buffer
ELC vc/vc-src.elc
In end of data:
vc/vc-src.el:314:1:Warning: the function ‘vc-setup-buffer’ might not be
defined at runtime.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: vc.diff --]
[-- Type: text/x-diff; name="vc.diff", Size: 1504 bytes --]
diff --git a/lisp/vc/vc-bzr.el b/lisp/vc/vc-bzr.el
index 03c134a..ffea8d2 100644
--- a/lisp/vc/vc-bzr.el
+++ b/lisp/vc/vc-bzr.el
@@ -45,6 +45,8 @@ vc-bzr-checkout-model
;;; Code:
+(require 'vc)
+
(eval-when-compile
(require 'cl-lib)
(require 'vc-dispatcher)
diff --git a/lisp/vc/vc-cvs.el b/lisp/vc/vc-cvs.el
index 2dca708..d8f7bcf 100644
--- a/lisp/vc/vc-cvs.el
+++ b/lisp/vc/vc-cvs.el
@@ -25,7 +25,7 @@
;;; Code:
-(eval-when-compile (require 'vc))
+(require 'vc)
;; Clear up the cache to force vc-call to check again and discover
;; new functions when we reload this file.
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el
index 5fb93bc..e87a3ce 100644
--- a/lisp/vc/vc-hg.el
+++ b/lisp/vc/vc-hg.el
@@ -101,6 +101,8 @@
;;; Code:
+(require 'vc-dispatcher)
+
(eval-when-compile
(require 'cl-lib)
(require 'vc)
diff --git a/lisp/vc/vc-rcs.el b/lisp/vc/vc-rcs.el
index b972956..99c3c20 100644
--- a/lisp/vc/vc-rcs.el
+++ b/lisp/vc/vc-rcs.el
@@ -37,9 +37,10 @@
;;; Customization options
;;;
+(require 'vc)
+
(eval-when-compile
- (require 'cl-lib)
- (require 'vc))
+ (require 'cl-lib))
(defgroup vc-rcs nil
"VC RCS backend."
diff --git a/lisp/vc/vc-src.el b/lisp/vc/vc-src.el
index 2329042..7bb5d0e 100644
--- a/lisp/vc/vc-src.el
+++ b/lisp/vc/vc-src.el
@@ -81,6 +81,8 @@
;;; Customization options
;;;
+(require 'vc-dispatcher)
+
(eval-when-compile
(require 'cl-lib)
(require 'vc))
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: pacifying "might not be defined at runtime" warning
2016-05-09 6:45 pacifying "might not be defined at runtime" warning Paul Eggert
@ 2016-05-09 12:20 ` Stefan Monnier
2016-05-09 16:35 ` Paul Eggert
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2016-05-09 12:20 UTC (permalink / raw)
To: emacs-devel
> "cd lisp; make compile-always" generates several "might not be defined at
> runtime" warnings in the master branch. For example, it generates the attached
> warnings in lisp/vc.
[ Note: when I say "vc.el" below, it includes generic VC
files other than vc-hooks.el, such as vc-dispatch.el. ]
The vc-<backend>.el files provide implementations for the functions used
in vc-hooks.el as well as for those used in vc.el.
In the parts that implement the vc.el functionality, it's "perfectly
safe" to call functions provided by vc.el, since they're supposed to
only be used *from* vc.el (i.e. when vc.el is already loaded).
> Is there some reason we shouldn't add directives like
> (require 'vc) to pacify the byte compiler here? (See the 2nd attachment.)
The reason is that vc-<backend>.el is autoloaded as soon as you visit
a file that's managed by <backend>, even if you never have and never
will use VC, so a (require 'vc) in those files would load VC
too eagerly.
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: pacifying "might not be defined at runtime" warning
2016-05-09 12:20 ` Stefan Monnier
@ 2016-05-09 16:35 ` Paul Eggert
2016-05-09 16:37 ` Dmitry Gutov
2016-05-09 16:40 ` Eli Zaretskii
0 siblings, 2 replies; 7+ messages in thread
From: Paul Eggert @ 2016-05-09 16:35 UTC (permalink / raw)
To: Stefan Monnier, emacs-devel
On 05/09/2016 05:20 AM, Stefan Monnier wrote:
> vc-<backend>.el is autoloaded as soon as you visit
> a file that's managed by <backend>, even if you never have and never
> will use VC, so a (require 'vc) in those files would load VC
> too eagerly.
Thanks for explaining. What is the recommended way to pacify the byte
compiler in this situation? I tried prepending (eval-when-compile
(require 'vc)) to vc-bzr.el, but that doesn’t suffice, as the
byte-compiler still complains “vc/vc-bzr.el:1337:1:Warning: the function
‘vc-deduce-fileset’ might not be defined at runtime.”
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: pacifying "might not be defined at runtime" warning
2016-05-09 16:35 ` Paul Eggert
@ 2016-05-09 16:37 ` Dmitry Gutov
2016-05-09 16:40 ` Eli Zaretskii
1 sibling, 0 replies; 7+ messages in thread
From: Dmitry Gutov @ 2016-05-09 16:37 UTC (permalink / raw)
To: Paul Eggert, Stefan Monnier, emacs-devel
On 05/09/2016 07:35 PM, Paul Eggert wrote:
> Thanks for explaining. What is the recommended way to pacify the byte
> compiler in this situation?
declare-function, probably.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: pacifying "might not be defined at runtime" warning
2016-05-09 16:35 ` Paul Eggert
2016-05-09 16:37 ` Dmitry Gutov
@ 2016-05-09 16:40 ` Eli Zaretskii
2016-05-09 17:34 ` Paul Eggert
1 sibling, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2016-05-09 16:40 UTC (permalink / raw)
To: Paul Eggert; +Cc: monnier, emacs-devel
> From: Paul Eggert <eggert@cs.ucla.edu>
> Date: Mon, 9 May 2016 09:35:41 -0700
>
> What is the recommended way to pacify the byte compiler in this
> situation?
Does using declare-function help?
> I tried prepending (eval-when-compile (require 'vc)) to vc-bzr.el,
> but that doesn’t suffice, as the byte-compiler still complains
> “vc/vc-bzr.el:1337:1:Warning: the function ‘vc-deduce-fileset’ might
> not be defined at runtime.”
Yes, because the complaint is about _run_ time, and eval-when-compile
only helps at _compile_ time.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: pacifying "might not be defined at runtime" warning
2016-05-09 16:40 ` Eli Zaretskii
@ 2016-05-09 17:34 ` Paul Eggert
2016-05-09 18:03 ` Eli Zaretskii
0 siblings, 1 reply; 7+ messages in thread
From: Paul Eggert @ 2016-05-09 17:34 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: monnier, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 337 bytes --]
On 05/09/2016 09:40 AM, Eli Zaretskii wrote:
>> What is the recommended way to pacify the byte compiler in this
>> >situation?
> Does using declare-function help?
>
Yes, the attached patches suffice to pacify the byte compiler for the
source files under lisp/vc. If this is the recommended way to pacify,
I'll install them in master.
[-- Attachment #2: vc.diff --]
[-- Type: text/x-patch, Size: 2388 bytes --]
diff --git a/lisp/vc/vc-bzr.el b/lisp/vc/vc-bzr.el
index 03c134a..4bcab66 100644
--- a/lisp/vc/vc-bzr.el
+++ b/lisp/vc/vc-bzr.el
@@ -50,6 +50,11 @@ vc-bzr-checkout-model
(require 'vc-dispatcher)
(require 'vc-dir)) ; vc-dir-at-event
+(declare-function vc-deduce-fileset "vc"
+ (&optional observer allow-unregistered
+ state-model-only-files))
+
+
;; Clear up the cache to force vc-call to check again and discover
;; new functions when we reload this file.
(put 'Bzr 'vc-functions nil)
diff --git a/lisp/vc/vc-cvs.el b/lisp/vc/vc-cvs.el
index 2dca708..dfe6b29 100644
--- a/lisp/vc/vc-cvs.el
+++ b/lisp/vc/vc-cvs.el
@@ -27,6 +27,12 @@
(eval-when-compile (require 'vc))
+(declare-function vc-branch-p "vc" (rev))
+(declare-function vc-checkout "vc" (file &optional rev))
+(declare-function vc-expand-dirs "vc" (file-or-dir-list backend))
+(declare-function vc-read-revision "vc"
+ (prompt &optional files backend default initial-input))
+
;; Clear up the cache to force vc-call to check again and discover
;; new functions when we reload this file.
(put 'CVS 'vc-functions nil)
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el
index 5fb93bc..78ff56c 100644
--- a/lisp/vc/vc-hg.el
+++ b/lisp/vc/vc-hg.el
@@ -106,6 +106,8 @@
(require 'vc)
(require 'vc-dir))
+(declare-function vc-compilation-mode "vc-dispatcher" (backend))
+
;;; Customization options
(defgroup vc-hg nil
diff --git a/lisp/vc/vc-rcs.el b/lisp/vc/vc-rcs.el
index b972956..fcb1849 100644
--- a/lisp/vc/vc-rcs.el
+++ b/lisp/vc/vc-rcs.el
@@ -41,6 +41,13 @@
(require 'cl-lib)
(require 'vc))
+(declare-function vc-branch-p "vc" (rev))
+(declare-function vc-read-revision "vc"
+ (prompt &optional files backend default initial-input))
+(declare-function vc-buffer-context "vc-dispatcher" ())
+(declare-function vc-restore-buffer-context "vc-dispatcher" (context))
+(declare-function vc-setup-buffer "vc-dispatcher" (buf))
+
(defgroup vc-rcs nil
"VC RCS backend."
:version "24.1"
diff --git a/lisp/vc/vc-src.el b/lisp/vc/vc-src.el
index 2329042..8b82b56 100644
--- a/lisp/vc/vc-src.el
+++ b/lisp/vc/vc-src.el
@@ -85,6 +85,8 @@
(require 'cl-lib)
(require 'vc))
+(declare-function vc-setup-buffer "vc-dispatcher" (buf))
+
(defgroup vc-src nil
"VC SRC backend."
:version "25.1"
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: pacifying "might not be defined at runtime" warning
2016-05-09 17:34 ` Paul Eggert
@ 2016-05-09 18:03 ` Eli Zaretskii
0 siblings, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2016-05-09 18:03 UTC (permalink / raw)
To: Paul Eggert; +Cc: monnier, emacs-devel
> Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org
> From: Paul Eggert <eggert@cs.ucla.edu>
> Date: Mon, 9 May 2016 10:34:34 -0700
>
> > Does using declare-function help?
> >
> Yes, the attached patches suffice to pacify the byte compiler for the
> source files under lisp/vc. If this is the recommended way to pacify,
> I'll install them in master.
I believe this is the way, yes.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-05-09 18:03 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-09 6:45 pacifying "might not be defined at runtime" warning Paul Eggert
2016-05-09 12:20 ` Stefan Monnier
2016-05-09 16:35 ` Paul Eggert
2016-05-09 16:37 ` Dmitry Gutov
2016-05-09 16:40 ` Eli Zaretskii
2016-05-09 17:34 ` Paul Eggert
2016-05-09 18:03 ` Eli Zaretskii
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).