emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: add-change-log-entry


From: Alan Mackenzie
Subject: Re: add-change-log-entry
Date: Mon, 23 Jul 2007 15:38:20 +0000
User-agent: Mutt/1.5.9i

On Mon, Jul 23, 2007 at 12:28:09AM -0400, Richard Stallman wrote:
> What does the byte-compiler bug consist of?

emacs -Q

Evaluate the following:

(defun foo ()
  (bar))
(byte-compile 'foo)
(defun bar ())
(byte-compile 'bar)

Now do M-: byte-compile-file <CR> .../emacs/lisp/emacs-lisp/bytecomp.el
(or any other file, for that matter).

This gives the following message:
In end of data:
bytecomp.el:4256:1:Warning: the function `bar' might not be defined at
    runtime.

> What does your patch intend to do?

The bug happens because the variable byte-compile-unresolved-functions
is cleared at the END of a compilation rather than being initialised at
the beginning of it.  In the recipe above, it's value is ((bar 0)) at
the start of the compilation.

My patch initialises the variable correctly at the start of
byte-compile-file, and also makes the variable's doc string less vague,
this vagueness probably being what made the original hacker scared to
initialise it in the first place.

The following patch is against the Emacs 22 branch:



2007-07-23  Alan Mackenzie  <address@hidden>

        * emacs-lisp/bytecomp.el (byte-compile-from-buffer): initialise
        byte-compile-unresolved-functions before rather than after a
        compilation.
        (byte-compile-unresolved-functions): Amplify doc string.


Index: bytecomp.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/emacs-lisp/bytecomp.el,v
retrieving revision 2.198
diff -c -r2.198 bytecomp.el
*** bytecomp.el 11 Apr 2007 03:59:20 -0000      2.198
--- bytecomp.el 23 Jul 2007 15:26:07 -0000
***************
*** 476,482 ****
  
  (defvar byte-compile-unresolved-functions nil
    "Alist of undefined functions to which calls have been compiled.
! Used for warnings when the function is not known to be defined or is later
  defined with incorrect args.")
  
  (defvar byte-compile-noruntime-functions nil
--- 476,483 ----
  
  (defvar byte-compile-unresolved-functions nil
    "Alist of undefined functions to which calls have been compiled.
! This variable is only significant whilst compiling an entire buffer.
! Used for warnings when a function is not known to be defined or is later
  defined with incorrect args.")
  
  (defvar byte-compile-noruntime-functions nil
***************
*** 1848,1853 ****
--- 1849,1859 ----
        (save-excursion
        (set-buffer inbuffer)
        (goto-char 1)
+       ;; Should we always do this?  When calling multiple files, it
+       ;; would be useful to delay this warning until all have been
+       ;; compiled.  A: Yes!  b-c-u-f might contain dross from a
+       ;; previous byte-compile.
+       (setq byte-compile-unresolved-functions nil)
  
        ;; Compile the forms from the input buffer.
        (while (progn
***************
*** 1864,1874 ****
        ;; Make warnings about unresolved functions
        ;; give the end of the file as their position.
        (setq byte-compile-last-position (point-max))
!       (byte-compile-warn-about-unresolved-functions)
!       ;; Should we always do this?  When calling multiple files, it
!       ;; would be useful to delay this warning until all have
!       ;; been compiled.
!       (setq byte-compile-unresolved-functions nil))
        ;; Fix up the header at the front of the output
        ;; if the buffer contains multibyte characters.
        (and filename (byte-compile-fix-header filename inbuffer outbuffer))))
--- 1870,1876 ----
        ;; Make warnings about unresolved functions
        ;; give the end of the file as their position.
        (setq byte-compile-last-position (point-max))
!       (byte-compile-warn-about-unresolved-functions))
        ;; Fix up the header at the front of the output
        ;; if the buffer contains multibyte characters.
        (and filename (byte-compile-fix-header filename inbuffer outbuffer))))


-- 
Alan Mackenzie (Ittersbach, Germany).




reply via email to

[Prev in Thread] Current Thread [Next in Thread]