all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Richard Stallman <rms@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: add-change-log-entry
Date: Mon, 23 Jul 2007 15:38:20 +0000	[thread overview]
Message-ID: <20070723153820.GC2768@muc.de> (raw)
In-Reply-To: <E1ICpWj-0002rp-CR@fencepost.gnu.org>

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  <acm@muc.de>

	* 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	other threads:[~2007-07-23 15:38 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-16 19:09 add-change-log-entry Paul Pogonyshev
2007-07-17 15:05 ` add-change-log-entry Richard Stallman
2007-07-18  9:02   ` add-change-log-entry martin rudalics
2007-07-18 13:54     ` add-change-log-entry Sam Steingold
2007-07-18 14:32       ` add-change-log-entry martin rudalics
2007-07-18 18:58         ` add-change-log-entry Stefan Monnier
2007-07-18 21:32           ` add-change-log-entry martin rudalics
2007-07-19 21:20             ` add-change-log-entry Richard Stallman
2007-07-20  8:27               ` add-change-log-entry martin rudalics
2007-07-20 16:07                 ` add-change-log-entry Stefan Monnier
2007-07-21  9:09                   ` add-change-log-entry martin rudalics
2007-07-22  1:49                     ` add-change-log-entry Richard Stallman
2007-07-22  8:44                       ` add-change-log-entry martin rudalics
2007-07-22  9:02                         ` add-change-log-entry Andreas Schwab
2007-07-22  9:31                           ` add-change-log-entry martin rudalics
2007-07-22 13:24                         ` add-change-log-entry Alan Mackenzie
2007-07-22 21:00                           ` add-change-log-entry martin rudalics
2007-07-23  3:22                             ` add-change-log-entry Stefan Monnier
2007-07-23  4:28                           ` add-change-log-entry Richard Stallman
2007-07-23 15:38                             ` Alan Mackenzie [this message]
2007-07-23 22:31                               ` add-change-log-entry Richard Stallman
2007-07-24  8:19                                 ` add-change-log-entry Alan Mackenzie
2007-07-19 12:23         ` add-change-log-entry Richard Stallman

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=20070723153820.GC2768@muc.de \
    --to=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    --cc=rms@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.