unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stephen Gildea <stepheng+emacs@gildea.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: master 11860f8: * test/src/comp-tests.el: Eliminate byte-compiler warnings (Bug#52105).
Date: Fri, 26 Nov 2021 20:24:57 -0800	[thread overview]
Message-ID: <2586873.1637987097@tigger3.sg.gildea.net> (raw)
In-Reply-To: Message from monnier@iro.umontreal.ca of 26 Nov 2021 12:27:46 -0500 <jwvv90e7rw4.fsf-monnier+emacs@gnu.org>

Stefan Monnier <monnier@iro.umontreal.ca> wrote:

>   > +(eval-when-compile
>   > +  (require 'cl-lib)
>   > +  (require 'comp))
>   > +(eval-and-compile
>   > +  (require 'comp-cstr)          ;in eval-and-compile for its defstruct
>   > +  (defconst comp-test-src (ert-resource-file "comp-test-funcs.el"))
>   > +  (defconst comp-test-dyn-src (ert-resource-file "comp-test-funcs-dyn.el"))
>   > +  (defconst comp-test-pure-src (ert-resource-file "comp-test-pure.el"))
>   > +  (defconst comp-test-45603-src (ert-resource-file "comp-test-45603.el"))
>   > +  ;; Load the test code here so the compiler can check the function
>   > +  ;; names used in this file.
>   > +  (load comp-test-src nil t)
>   > +  (load comp-test-dyn-src nil t)
>   > +  (load comp-test-pure-src nil t)
>   > +  (load comp-test-45603-src nil t))
>   
>   This looks pretty ugly, in my book.
>   
>   Were the warnings false positives or were they diagnosing real problems?

False positives.  comp-tests.el compiles some test functions, then
examines the result, referring to the test functions by name.  The
test functions are in resource files, so the compiler thinks they are
undefined (and emits warnings) unless the functions are loaded when
comp-tests.el is compiled.

>   The cleanup could start by moving the (require 'comp-cstr) outside of
>   the `eval-and-compile` since toplevel `require`s are processed both at
>   compile and run time anyway.

I didn't know that.  So the "(eval-when-compile (require 'cl-lib))" is
wrong, too?  Here and in hundreds of other Emacs Lisp files?

The test functions here could be loaded with "require" instead of
"load", and then they could be moved outside of the "eval-and-compile"
form.  Would that be more elegant?

We could go even further and eliminate the "defconst" forms, calling
"ert-resource-file" twice for each file (once here for the "require",
and once below for the "native-compile").  That rewrite would
eliminate the ugly "eval-and-compile" entirely.

 < Stephen



  reply	other threads:[~2021-11-27  4:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20211126165428.32132.80341@vcs0.savannah.gnu.org>
     [not found] ` <20211126165429.C9F2F20983@vcs0.savannah.gnu.org>
2021-11-26 17:27   ` master 11860f8: * test/src/comp-tests.el: Eliminate byte-compiler warnings (Bug#52105) Stefan Monnier
2021-11-27  4:24     ` Stephen Gildea [this message]
2021-11-27 15:11       ` Stefan Monnier

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2586873.1637987097@tigger3.sg.gildea.net \
    --to=stepheng+emacs@gildea.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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 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).