unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#21963: Spurious byte compile message: "Warning: the function `bar' might not be defined at runtime."
@ 2015-11-20 10:44 Alan Mackenzie
  2015-11-20 11:19 ` Eli Zaretskii
  2019-09-29 21:24 ` Stefan Kangas
  0 siblings, 2 replies; 13+ messages in thread
From: Alan Mackenzie @ 2015-11-20 10:44 UTC (permalink / raw)
  To: 21963

Hello Emacs.

Using the latest from the emacs-25 branch:

This bug is a variant of bug #11918, which hasn't yet been resolved.

1. Create two Emacs Lisp source files, ~/warnings-bar.el and
~/warnings-foo.el with the following contents:

;;;;;;;; warnings-bar.el ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun bar ()
  "Doc string"
  "bar")

(provide 'warning-bar)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;; warnings-foo.el ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(eval-when-compile (require 'warning-bar))
(require 'warning-bar)

(defun foo ()
  (bar))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



2. (Optional) byte compile warnings-bar.el.
3. Byte compile warnings-foo.el with:
    emacs -Q -batch -L ~ -f batch-byte-compile warning-foo.el

.  This produces the spurious warning message:

    warning-foo.el:6:1:Warning: the function `bar' might not be defined
    at runtime.

.

N.B. if the `eval-when-compile' form is removed from warnings-foo.el, the
warning is not produced.

-- 
Alan Mackenzie (Nuremberg, Germany).





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#21963: Spurious byte compile message: "Warning: the function `bar' might not be defined at runtime."
  2015-11-20 10:44 bug#21963: Spurious byte compile message: "Warning: the function `bar' might not be defined at runtime." Alan Mackenzie
@ 2015-11-20 11:19 ` Eli Zaretskii
  2015-11-20 11:40   ` Alan Mackenzie
  2019-09-29 21:24 ` Stefan Kangas
  1 sibling, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2015-11-20 11:19 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: 21963

> Date: Fri, 20 Nov 2015 10:44:19 +0000
> From: Alan Mackenzie <acm@muc.de>
> 
> This bug is a variant of bug #11918, which hasn't yet been resolved.

I'm not sure this is the same issue.

> 1. Create two Emacs Lisp source files, ~/warnings-bar.el and
> ~/warnings-foo.el with the following contents:
> 
> ;;;;;;;; warnings-bar.el ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> (defun bar ()
>   "Doc string"
>   "bar")
> 
> (provide 'warning-bar)
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> 
> 
> ;;;;;;;; warnings-foo.el ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> (eval-when-compile (require 'warning-bar))
> (require 'warning-bar)
> 
> (defun foo ()
>   (bar))
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> 
> 
> 
> 2. (Optional) byte compile warnings-bar.el.
> 3. Byte compile warnings-foo.el with:
>     emacs -Q -batch -L ~ -f batch-byte-compile warning-foo.el
> 
> .  This produces the spurious warning message:
> 
>     warning-foo.el:6:1:Warning: the function `bar' might not be defined
>     at runtime.
> 
> .

eval-when-compile has no effect at run time, and the warning is
explicitly about what might happen at runtime.

IOW, I don't think this is a bug.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#21963: Spurious byte compile message: "Warning: the function `bar' might not be defined at runtime."
  2015-11-20 11:19 ` Eli Zaretskii
@ 2015-11-20 11:40   ` Alan Mackenzie
  2015-11-20 14:48     ` Eli Zaretskii
  0 siblings, 1 reply; 13+ messages in thread
From: Alan Mackenzie @ 2015-11-20 11:40 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 21963

Hello, Eli.

On Fri, Nov 20, 2015 at 01:19:19PM +0200, Eli Zaretskii wrote:
> > Date: Fri, 20 Nov 2015 10:44:19 +0000
> > From: Alan Mackenzie <acm@muc.de>

> > This bug is a variant of bug #11918, which hasn't yet been resolved.

> I'm not sure this is the same issue.

Possibly not.

> > 1. Create two Emacs Lisp source files, ~/warnings-bar.el and
> > ~/warnings-foo.el with the following contents:

> > ;;;;;;;; warnings-bar.el ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> > (defun bar ()
> >   "Doc string"
> >   "bar")

> > (provide 'warning-bar)
> > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


> > ;;;;;;;; warnings-foo.el ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> > (eval-when-compile (require 'warning-bar))
> > (require 'warning-bar)

> > (defun foo ()
> >   (bar))
> > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



> > 2. (Optional) byte compile warnings-bar.el.
> > 3. Byte compile warnings-foo.el with:
> >     emacs -Q -batch -L ~ -f batch-byte-compile warning-foo.el

> > .  This produces the spurious warning message:

> >     warning-foo.el:6:1:Warning: the function `bar' might not be defined
> >     at runtime.

> > .

> eval-when-compile has no effect at run time, and the warning is
> explicitly about what might happen at runtime.

> IOW, I don't think this is a bug.

It is, at the very least, puzzling behaviour.  The warning is issued for
a function that most definitely has been defined at runtime.

What seems to be happening (I'm speculating a little) is that the byte
compiler maintains a list of not-yet-defined functions in
byte-compile-unresolved-functions.  Functions defined at compile time
are pushed onto this list.  The problem is that when they are later
defined for run time, they aren't taken off the list.

Given that we've all been asked to get rid of warnings for 25.1, I have
to disagree with you about whether this is a bug.

-- 
Alan Mackenzie (Nuremberg, Germany).





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#21963: Spurious byte compile message: "Warning: the function `bar' might not be defined at runtime."
  2015-11-20 11:40   ` Alan Mackenzie
@ 2015-11-20 14:48     ` Eli Zaretskii
  2015-11-20 15:26       ` Alan Mackenzie
  0 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2015-11-20 14:48 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: 21963

> Date: Fri, 20 Nov 2015 11:40:50 +0000
> Cc: 21963@debbugs.gnu.org
> From: Alan Mackenzie <acm@muc.de>
> 
> > eval-when-compile has no effect at run time, and the warning is
> > explicitly about what might happen at runtime.
> 
> > IOW, I don't think this is a bug.
> 
> It is, at the very least, puzzling behaviour.  The warning is issued for
> a function that most definitely has been defined at runtime.

No, it was not (or, more accurately, will not be).  'eval-when-compile'
does nothing to make sure it will be defined at runtime; you need
either 'require' or 'eval-and-compile'.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#21963: Spurious byte compile message: "Warning: the function `bar' might not be defined at runtime."
  2015-11-20 14:48     ` Eli Zaretskii
@ 2015-11-20 15:26       ` Alan Mackenzie
  2015-11-20 15:48         ` Eli Zaretskii
  0 siblings, 1 reply; 13+ messages in thread
From: Alan Mackenzie @ 2015-11-20 15:26 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 21963

Hello, Eli.

On Fri, Nov 20, 2015 at 04:48:13PM +0200, Eli Zaretskii wrote:
> > Date: Fri, 20 Nov 2015 11:40:50 +0000
> > Cc: 21963@debbugs.gnu.org
> > From: Alan Mackenzie <acm@muc.de>

> > > eval-when-compile has no effect at run time, and the warning is
> > > explicitly about what might happen at runtime.

> > > IOW, I don't think this is a bug.

> > It is, at the very least, puzzling behaviour.  The warning is issued for
> > a function that most definitely has been defined at runtime.

> No, it was not (or, more accurately, will not be).  'eval-when-compile'
> does nothing to make sure it will be defined at runtime; you need
> either 'require' or 'eval-and-compile'.

The first two lines of the file are:

   (eval-when-compile (require 'warning-bar))
   (require 'warning-bar)
 
The second line will define the function `bar' at run time.

The byte-compiler has already decided after the first line that `bar' is
not defined at run time (fair enough), but seems unwilling to change its
mind after the second line.

This isn't just an academic problem.  CC Mode uses such sequences (in
effect), producing warnings in the Emacs build.

-- 
Alan Mackenzie (Nuremberg, Germany).





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#21963: Spurious byte compile message: "Warning: the function `bar' might not be defined at runtime."
  2015-11-20 15:26       ` Alan Mackenzie
@ 2015-11-20 15:48         ` Eli Zaretskii
  2015-11-20 16:01           ` John Wiegley
  0 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2015-11-20 15:48 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: 21963

> Date: Fri, 20 Nov 2015 15:26:38 +0000
> Cc: 21963@debbugs.gnu.org
> From: Alan Mackenzie <acm@muc.de>
> 
> The first two lines of the file are:
> 
>    (eval-when-compile (require 'warning-bar))
>    (require 'warning-bar)

I think if you leave only the second one, Bob's your uncle.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#21963: Spurious byte compile message: "Warning: the function `bar' might not be defined at runtime."
  2015-11-20 15:48         ` Eli Zaretskii
@ 2015-11-20 16:01           ` John Wiegley
  2015-11-20 16:15             ` Alan Mackenzie
  0 siblings, 1 reply; 13+ messages in thread
From: John Wiegley @ 2015-11-20 16:01 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Alan Mackenzie, 21963

>>>>> Eli Zaretskii <eliz@gnu.org> writes:

>> (eval-when-compile (require 'warning-bar))
>> (require 'warning-bar)

> I think if you leave only the second one, Bob's your uncle.

I think the question is: Why does haven't the first one cause the definedness
introduced by the second to not be recognized?

John





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#21963: Spurious byte compile message: "Warning: the function `bar' might not be defined at runtime."
  2015-11-20 16:01           ` John Wiegley
@ 2015-11-20 16:15             ` Alan Mackenzie
  2015-11-20 16:44               ` John Wiegley
  0 siblings, 1 reply; 13+ messages in thread
From: Alan Mackenzie @ 2015-11-20 16:15 UTC (permalink / raw)
  To: John Wiegley; +Cc: 21963

Hello, John.

On Fri, Nov 20, 2015 at 08:01:31AM -0800, John Wiegley wrote:
> >>>>> Eli Zaretskii <eliz@gnu.org> writes:

> >> (eval-when-compile (require 'warning-bar))
> >> (require 'warning-bar)

> > I think if you leave only the second one, Bob's your uncle.

> I think the question is: Why does haven't the first one cause the definedness
> introduced by the second to not be recognized?

While eval-when-compile'ing the first line, the byte compiler collects a
list of symbols defined by it (in variable
byte-compile-noruntime-functions).  More or less.

There is no mechanism for taking symbols off of that list when they
subsequently become defined.

> John

-- 
Alan Mackenzie (Nuremberg, Germany).





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#21963: Spurious byte compile message: "Warning: the function `bar' might not be defined at runtime."
  2015-11-20 16:15             ` Alan Mackenzie
@ 2015-11-20 16:44               ` John Wiegley
  2015-11-20 17:50                 ` Alan Mackenzie
  0 siblings, 1 reply; 13+ messages in thread
From: John Wiegley @ 2015-11-20 16:44 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: 21963

>>>>> Alan Mackenzie <acm@muc.de> writes:

> While eval-when-compile'ing the first line, the byte compiler collects a
> list of symbols defined by it (in variable
> byte-compile-noruntime-functions). More or less.

> There is no mechanism for taking symbols off of that list when they
> subsequently become defined.

Not optimal, but I must ask: Should it be fixed? Or, for now, simply noted in
the elisp manual when discussing the merits of this warning?

John





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#21963: Spurious byte compile message: "Warning: the function `bar' might not be defined at runtime."
  2015-11-20 16:44               ` John Wiegley
@ 2015-11-20 17:50                 ` Alan Mackenzie
  0 siblings, 0 replies; 13+ messages in thread
From: Alan Mackenzie @ 2015-11-20 17:50 UTC (permalink / raw)
  To: John Wiegley; +Cc: 21963

Hello, John.

On Fri, Nov 20, 2015 at 08:44:56AM -0800, John Wiegley wrote:
> >>>>> Alan Mackenzie <acm@muc.de> writes:

> > While eval-when-compile'ing the first line, the byte compiler collects a
> > list of symbols defined by it (in variable
> > byte-compile-noruntime-functions). More or less.

> > There is no mechanism for taking symbols off of that list when they
> > subsequently become defined.

> Not optimal, but I must ask: Should it be fixed? Or, for now, simply noted in
> the elisp manual when discussing the merits of this warning?

I think it should be fixed.  It will eliminate warnings from CC Mode (at
the very least).

I am working on it as we speak.  I expect to produce a patch for review
soon.

> John

-- 
Alan Mackenzie (Nuremberg, Germany).





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#21963: Spurious byte compile message: "Warning: the function `bar' might not be defined at runtime."
  2015-11-20 10:44 bug#21963: Spurious byte compile message: "Warning: the function `bar' might not be defined at runtime." Alan Mackenzie
  2015-11-20 11:19 ` Eli Zaretskii
@ 2019-09-29 21:24 ` Stefan Kangas
  2019-09-30 18:22   ` Alan Mackenzie
  1 sibling, 1 reply; 13+ messages in thread
From: Stefan Kangas @ 2019-09-29 21:24 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: John Wiegley, 21963

Alan Mackenzie <acm@muc.de> writes:

> On Fri, Nov 20, 2015 at 08:44:56AM -0800, John Wiegley wrote:
>> >>>>> Alan Mackenzie <acm@muc.de> writes:
>
>> > While eval-when-compile'ing the first line, the byte compiler collects a
>> > list of symbols defined by it (in variable
>> > byte-compile-noruntime-functions). More or less.
>
>> > There is no mechanism for taking symbols off of that list when they
>> > subsequently become defined.
>
>> Not optimal, but I must ask: Should it be fixed? Or, for now, simply noted in
>> the elisp manual when discussing the merits of this warning?
>
> I think it should be fixed.  It will eliminate warnings from CC Mode (at
> the very least).
>
> I am working on it as we speak.  I expect to produce a patch for review
> soon.

Hi Alan,

That was four years ago.  Did you finish the patch which would resolve
this issue?

Best regards,
Stefan Kangas





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#21963: Spurious byte compile message: "Warning: the function `bar' might not be defined at runtime."
  2019-09-29 21:24 ` Stefan Kangas
@ 2019-09-30 18:22   ` Alan Mackenzie
  2019-09-30 21:24     ` Stefan Kangas
  0 siblings, 1 reply; 13+ messages in thread
From: Alan Mackenzie @ 2019-09-30 18:22 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: John Wiegley, 21963

Hello, Stefan.

On Sun, Sep 29, 2019 at 23:24:29 +0200, Stefan Kangas wrote:
> Alan Mackenzie <acm@muc.de> writes:

> > On Fri, Nov 20, 2015 at 08:44:56AM -0800, John Wiegley wrote:
> >> >>>>> Alan Mackenzie <acm@muc.de> writes:

> >> > While eval-when-compile'ing the first line, the byte compiler collects a
> >> > list of symbols defined by it (in variable
> >> > byte-compile-noruntime-functions). More or less.

> >> > There is no mechanism for taking symbols off of that list when they
> >> > subsequently become defined.

> >> Not optimal, but I must ask: Should it be fixed? Or, for now, simply noted in
> >> the elisp manual when discussing the merits of this warning?

> > I think it should be fixed.  It will eliminate warnings from CC Mode (at
> > the very least).

> > I am working on it as we speak.  I expect to produce a patch for review
> > soon.

> Hi Alan,

> That was four years ago.  Did you finish the patch which would resolve
> this issue?

Yes, I did indeed; with this patch:

acb96f2718ccb0d36af514ce63b5decf0f24a697
Squashed commit of the following: .....
Tue Nov 24 17:37:49 2015 +0000

Sorry I forgot to close the bug.

> Best regards,
> Stefan Kangas

-- 
Alan Mackenzie (Nuremberg, Germany).





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#21963: Spurious byte compile message: "Warning: the function `bar' might not be defined at runtime."
  2019-09-30 18:22   ` Alan Mackenzie
@ 2019-09-30 21:24     ` Stefan Kangas
  0 siblings, 0 replies; 13+ messages in thread
From: Stefan Kangas @ 2019-09-30 21:24 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: John Wiegley, 21963

close 21963 25.1
quit

> > That was four years ago.  Did you finish the patch which would resolve
> > this issue?
>
> Yes, I did indeed; with this patch:
>
> acb96f2718ccb0d36af514ce63b5decf0f24a697
> Squashed commit of the following: .....
> Tue Nov 24 17:37:49 2015 +0000
>
> Sorry I forgot to close the bug.

Thanks; closed now.

Best regards,
Stefan Kangas





^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-09-30 21:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-20 10:44 bug#21963: Spurious byte compile message: "Warning: the function `bar' might not be defined at runtime." Alan Mackenzie
2015-11-20 11:19 ` Eli Zaretskii
2015-11-20 11:40   ` Alan Mackenzie
2015-11-20 14:48     ` Eli Zaretskii
2015-11-20 15:26       ` Alan Mackenzie
2015-11-20 15:48         ` Eli Zaretskii
2015-11-20 16:01           ` John Wiegley
2015-11-20 16:15             ` Alan Mackenzie
2015-11-20 16:44               ` John Wiegley
2015-11-20 17:50                 ` Alan Mackenzie
2019-09-29 21:24 ` Stefan Kangas
2019-09-30 18:22   ` Alan Mackenzie
2019-09-30 21:24     ` Stefan Kangas

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).