Subject: bug#24449: Emacs 25.1 RC2: Byte compiler reports error in wrong place.

From: Alan Mackenzie <[email-masked]>
Date: Sat, 17 Sep 2016 08:29:52 +0000

Hello, Eli.

On Fri, Sep 16, 2016 at 10:03:54PM +0300, Eli Zaretskii wrote:
> > Date: Fri, 16 Sep 2016 18:34:51 +0000
> > Cc: [email-masked]
> > From: Alan Mackenzie <[email-masked]>
> > 
> > Comments?

> Please perform a full bootstrap and compare the warning messages
> before and after the change.  Then tell what you found.

This was actually very interesting.  I've never really looked at warning
messages all that closely before.  Here's what I saw:

1. The column numbers of all positions are irritatingly 1-based, so are
  1 off from the column number displayed in Emacs's mode line.

2. Most of the warnings are "foo is an obsolete function", for which the
  position given is only vaguely in the same area as the offending
  function, both with and without the change.  It seems that for this
  warning, `byte-compile-set-symbol-position' is not being called at
  all.  As an example of where the positions in the warnings differ:

(Before change):
emulation/viper.el:986:44:Warning: `interactive-p' is an obsolete function (as
    of 23.2); use `called-interactively-p' instead.
(After change):
emulation/viper.el:1023:69:Warning: `interactive-p' is an obsolete function
    (as of 23.2); use `called-interactively-p' instead.

  The actual occurrence of `interactive-p' is at 937:15.  Both of the
  positions given are at occurrences of the symbol `vi-state'.  It is
  perhaps a little worrying that the output positions are both beyond
  the actual position, suggesting that some call of
  `byte-compile-set-symbol-position' has already moved the position too
  far before this warning gets generated.

3. Most of the other warnings actually output were similarly vague in
  their positions.  This includes warnings generated by packages other
  than the byte compiler, e.g. cedet.

4. The three "free variable" warnings' inaccurate positions (before
change) were given accurate positions (after change).  As well as the
occurrence in cc-engine.el, we have:

(Before change):
org/org.el:12842:19:Warning: assignment to free variable `e'
org/org.el:12842:19:Warning: reference to free variable `e
(After change):
org/org.el:12840:20:Warning: assignment to free variable `e'
org/org.el:12840:20:Warning: reference to free variable `e'

5. The change I made yesterday appears not to have made anything any
  worse.

=========================================================================

What I would suggest should get done: we should make the column numbers
0-based; suitable places to call `byte-compile-set-symbol-position' for
the error messages we see should be identified, the calls inserted, and
another bootstrap build done to see how much this helps.

> Thanks.

-- 
Alan Mackenzie (Nuremberg, Germany).