unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* byte-compile-warn in do-after-load-evaluation - a bug?
@ 2022-01-21 17:28 Alan Mackenzie
  2022-01-21 18:39 ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Alan Mackenzie @ 2022-01-21 17:28 UTC (permalink / raw)
  To: emacs-devel

Hello, Emacs,

in master (at least), in do-after-load-evaluation (subr.el), the code
uses byte-compile-warn to output an error message.  This seems wierd,
since there's no mention of the byte compiler anywhere near.

Might it be that somebody not having a good day just used that function
thinking it was a general purpose warning function?

The problem with it is that it uses an implicit (compilation) source
position in the message it outputs.  There is no compilation going on at
the moment.

Unless I've misunderstood something, I propose to replace this call of
byte-compile-warn with simply message.

-- 
Alan Mackenzie (Nuremberg, Germany).



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

* Re: byte-compile-warn in do-after-load-evaluation - a bug?
  2022-01-21 17:28 byte-compile-warn in do-after-load-evaluation - a bug? Alan Mackenzie
@ 2022-01-21 18:39 ` Stefan Monnier
  2022-01-21 21:33   ` Alan Mackenzie
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2022-01-21 18:39 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: emacs-devel

> Might it be that somebody not having a good day just used that function
> thinking it was a general purpose warning function?

No, and I think the code makes it pretty clear:

    [...]
    (cond
     ((bound-and-true-p byte-compile-current-file)
      ;; Don't warn about obsolete files using other obsolete files.
      (unless (and (stringp byte-compile-current-file)
                   (string-match-p "/obsolete/[^/]*\\'"
                                   (expand-file-name
                                    byte-compile-current-file
                                    byte-compile-root-dir)))
        (byte-compile-warn "%s" msg)))
    [...]

The intention is to use this code when the load was performed by the
byte-compiler (presumably because of a `require`).

> The problem with it is that it uses an implicit (compilation) source
> position in the message it outputs.  There is no compilation going on at
> the moment.

I suspect that what we should do here is to make the byte-compiler
provide more info.  E.g. instead of just testing
`byte-compile-current-file`, which is a kind of "accidental" info, we
should have `bytecomp.el` do a

    (let ((byte-compile-triggered-load-source <sourcedata>))
      ...)

so `do-after-load-evaluation` can check this specific var and use its
info to provide proper source information.

WDYT?


        Stefan




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

* Re: byte-compile-warn in do-after-load-evaluation - a bug?
  2022-01-21 18:39 ` Stefan Monnier
@ 2022-01-21 21:33   ` Alan Mackenzie
  2022-01-21 22:11     ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Alan Mackenzie @ 2022-01-21 21:33 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Hello, Stefan.

On Fri, Jan 21, 2022 at 13:39:26 -0500, Stefan Monnier wrote:
> > Might it be that somebody not having a good day just used that function
> > thinking it was a general purpose warning function?

> No, and I think the code makes it pretty clear:

Sorry, yes it does.  I think it's me that's having the bad day.

>     [...]
>     (cond
>      ((bound-and-true-p byte-compile-current-file)
>       ;; Don't warn about obsolete files using other obsolete files.
>       (unless (and (stringp byte-compile-current-file)
>                    (string-match-p "/obsolete/[^/]*\\'"
>                                    (expand-file-name
>                                     byte-compile-current-file
>                                     byte-compile-root-dir)))
>         (byte-compile-warn "%s" msg)))
>     [...]

> The intention is to use this code when the load was performed by the
> byte-compiler (presumably because of a `require`).

I think I've got it sorted out, now.  By pushing an element onto
byte-compile-form-stack when handling a `require', we can ensure
byte-compile-warn will have something to chew on.
(scratch/correct-warning-pos branch.)

> > The problem with it is that it uses an implicit (compilation) source
> > position in the message it outputs.  There is no compilation going on at
> > the moment.

> I suspect that what we should do here is to make the byte-compiler
> provide more info.  E.g. instead of just testing
> `byte-compile-current-file`, which is a kind of "accidental" info, we
> should have `bytecomp.el` do a

>     (let ((byte-compile-triggered-load-source <sourcedata>))
>       ...)

> so `do-after-load-evaluation` can check this specific var and use its
> info to provide proper source information.

> WDYT?

I'm not convinced.  I think byte-compile-form-stack already provides (or
can provide) sufficient source position information.

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).



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

* Re: byte-compile-warn in do-after-load-evaluation - a bug?
  2022-01-21 21:33   ` Alan Mackenzie
@ 2022-01-21 22:11     ` Stefan Monnier
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2022-01-21 22:11 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: emacs-devel

> I'm not convinced.  I think byte-compile-form-stack already provides (or
> can provide) sufficient source position information.

Fair enough,


        Stefan




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

end of thread, other threads:[~2022-01-21 22:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-21 17:28 byte-compile-warn in do-after-load-evaluation - a bug? Alan Mackenzie
2022-01-21 18:39 ` Stefan Monnier
2022-01-21 21:33   ` Alan Mackenzie
2022-01-21 22:11     ` Stefan Monnier

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