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.

Full log


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.




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.