GNU bug report logs - #20509
compiler warns about cl-defmethod defined after use

Previous Next

Package: emacs;

Reported by: Glenn Morris <rgm <at> gnu.org>

Date: Tue, 5 May 2015 18:17:02 UTC

Severity: normal

Found in version 25.0.50

Fixed in version 25.1

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 20509 in the body.
You can then email your comments to 20509 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#20509; Package emacs. (Tue, 05 May 2015 18:17:02 GMT) Full text and rfc822 format available.

Message #3 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: submit <at> debbugs.gnu.org
Subject: compiler warns about cl-defmethod defined after use
Date: Tue, 05 May 2015 14:16:14 -0400
Package: emacs
Version: 25.0.50

Compiling foo.el with contents:
    
    (require 'cl-lib)
    
    (defun foo-1 ()
      (foo-2))
    
    (cl-defmethod foo-2 ()
      t)

results in:

   In end of data:
   foo.el:8:1:Warning: the function `foo-2' is not known to be defined.


There is no such warning when using defun instead of cl-defmethod,
or if foo-2 is moved before foo-1.


I see that cl-defmethod macroexpands to something using declare-function.
Adding

  (setq byte-compile-unresolved-functions
       (delq (assq fn byte-compile-unresolved-functions)
             byte-compile-unresolved-functions))

to byte-compile-macroexpand-declare-function solves the issue,
but I'm not sure it is right, since it might stop
byte-compile-arglist-warn doing its job (?).

On the other hand, it would be consistent with what
byte-compile-file-form-autoload does (see comment in the code).

On the other other hand, declare-function's currently have to come
before any use of the function thay are declaring, which is somewhat
intentional.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20509; Package emacs. (Tue, 05 May 2015 20:01:03 GMT) Full text and rfc822 format available.

Message #6 received at 20509 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 20509 <at> debbugs.gnu.org
Subject: Re: bug#20509: compiler warns about cl-defmethod defined after use
Date: Tue, 05 May 2015 16:00:15 -0400
>     (require 'cl-lib)
>     (defun foo-1 ()
>       (foo-2))
>     (cl-defmethod foo-2 ()
>       t)

While using cl-defmethod without a previous cl-defgeneric is supported,
it's not recommended.


        Stefan




bug marked as fixed in version 25.1, send any further explanations to 20509 <at> debbugs.gnu.org and Glenn Morris <rgm <at> gnu.org> Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 06 May 2015 03:15:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20509; Package emacs. (Wed, 06 May 2015 03:18:02 GMT) Full text and rfc822 format available.

Message #11 received at 20509 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 20509 <at> debbugs.gnu.org
Subject: Re: bug#20509: compiler warns about cl-defmethod defined after use
Date: Tue, 05 May 2015 23:17:03 -0400
Stefan Monnier wrote:

> While using cl-defmethod without a previous cl-defgeneric is supported,
> it's not recommended.

It's used without one in several places in Emacs:

emacs-lisp/eieio-custom.el:472:1:Warning: the following functions are not
    known to be defined: eieio-customize-object,
    eieio-custom-object-apply-reset, eieio-custom-widget-insert

emacs-lisp/eieio-speedbar.el:426:1:Warning: the following functions are not
    known to be defined: eieio-speedbar-make-tag-line,
    eieio-speedbar-object-children, eieio-speedbar-expand

cedet/ede/base.el:662:1:Warning: the following functions are not known to be
    defined: ede-buffer-header-file, ede-target-sourcecode,
    ede-buffer-documentation-files, ede-documentation,
    ede-html-documentation

cedet/ede/config.el:417:1:Warning: the following functions are not known to be
    defined: ede-config-get-configuration,
    ede-config-setup-configuration,
    ede-commit

cedet/ede/custom.el:216:1:Warning: the following functions are not known to be
    defined: ede-customize, ede-commit-project


etc etc.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20509; Package emacs. (Wed, 06 May 2015 04:29:01 GMT) Full text and rfc822 format available.

Message #14 received at 20509 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 20509 <at> debbugs.gnu.org
Subject: Re: bug#20509: compiler warns about cl-defmethod defined after use
Date: Wed, 06 May 2015 00:28:12 -0400
>> While using cl-defmethod without a previous cl-defgeneric is supported,
>> it's not recommended.
> It's used without one in several places in Emacs:

That's because EIEIO's older `defmethod' always counted as
a "full" definition.  We can fix those warnings in one of the following ways:
- Add a corresponding cl-defgeneric.
- Add a corresponding `require' which loads the package where the
  corresponding `cl-defgeneric' is found.
- Reorder the code so that the cl-defmethod appears before the call(s).
- Change cl-generic.el to use the same kind of bytecompiler hack that
  eieio used to use instead if using `declare-function'.


        Stefan




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 03 Jun 2015 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 18 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.