emacs-pretest-bug
[Top][All Lists]
Advanced

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

`eval-when-compile' can cause incorrect byte-compiler warnings


From: Jesper Harder
Subject: `eval-when-compile' can cause incorrect byte-compiler warnings
Date: Thu, 15 Jan 2004 05:08:43 +0100
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

In GNU Emacs 21.3.50.23 (i686-pc-linux-gnu, GTK+ Version 2.0.2)
 of 2004-01-13 on defun.localdomain


Consider the two files 'file1.el' and 'file2.el':

------------------------------------------------------------
;;; file1.el
(eval-when-compile
  (require 'nnkiboze))

(nnkiboze-prefixed-name "foo")

;;; file1.el ends here
------------------------------------------------------------

------------------------------------------------------------
;;; file2.el
(require 'nnkiboze))

(nnkiboze-prefixed-name "foo")

;;; file2.el ends here
------------------------------------------------------------

If you compile them with:

  emacs -q --no-site-file --batch -f batch-byte-compile file?.el

you get these byte-compiler warnings:

,----
| In end of data:
| file1.el:4:1:Warning: the function `nnkiboze-prefixed-name' might not be
|     defined at runtime.
| Wrote /home/harder/tmp/file1.elc
| 
| In end of data:
| file2.el:3:1:Warning: the function `nnkiboze-prefixed-name' might not be
|     defined at runtime.
| Wrote /home/harder/tmp/file2.elc
`----

The warning for file1 is right, of course.  But the warning for file2
is obviously wrong.  This can be quite confusing if you're compiling
many files -- a change in one file can suddenly cause warnings in a
completely unrelated file.

It happens because the functions loaded from nnkiboze during
compilation of file1 are marked with the `byte-compile-noruntime'
property.  I think these properties should be cleared before
proceeding to the next file:

2004-01-15  Jesper Harder  <address@hidden>

        * bytecomp.el (byte-compile-from-buffer): Clear the
        byte-compile-noruntime property from all symbols before
        proceeding to the next file.

*** /home/harder/emacs/lisp/emacs-lisp/bytecomp.el      Tue Jan 13 05:24:54 2004
--- /home/harder/tmp/bytecomp.el        Thu Jan 15 04:35:46 2004
***************
*** 1752,1758 ****
        ;; 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))))
--- 1752,1759 ----
        ;; 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)
!       (mapatoms (lambda (s) (put s 'byte-compile-noruntime 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))))

reply via email to

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