GNU bug report logs -
#69120
Spurious "function is not known to be defined" if defined in `use-package` body
Previous Next
Full log
Message #23 received at 69120 <at> debbugs.gnu.org (full text, mbox):
On Wed, 2024-02-14 at 18:38 +0200, Eli Zaretskii wrote:
> > From: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
> > Cc: 69120 <at> debbugs.gnu.org
> > Date: Wed, 14 Feb 2024 19:10:54 +0300
> >
> > On Wed, 2024-02-14 at 18:07 +0200, Eli Zaretskii wrote:
> > > > From: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
> > > > Cc: 69120 <at> debbugs.gnu.org
> > > > Date: Wed, 14 Feb 2024 18:28:15 +0300
> > > >
> > > > > > test.el:6:4: Warning: the function ‘hello’ is not known
> > > > > > to
> > > > > > be
> > > > > > defined.
> > > > >
> > > > > What do you get if you macro-expand your code?
> > > >
> > > > Wrapping the above code to a `(macroexpand …)` gives a:
> > > >
> > > > "hello"
> > > > nil
> > >
> > > You need to quote the form you pass to macroexpand, to get the
> > > expansion, I think.
> >
> > Oh indeed you're right!
> >
> > It gives me the following:
> >
> > (progn (defvar use-package--warning196 #'(lambda (keyword err) (let
> > ((msg (format "%s/%s: %s" 'prog-mode keyword (error-message-string
> > err)))) (display-warning 'use-package msg :error)))) (condition-
> > case-unless-debug err (progn (condition-case-unless-debug err
> > (progn (defun hello nil (print "hello")) (hello)) (error (funcall
> > use-package--warning196 :init err))) (if (not (require 'prog-mode
> > nil t)) (display-warning 'use-package (format "Cannot load %s"
> > 'prog-mode) :error))) (error (funcall use-package--warning196
> > :catch err))))
>
> And that doesn't explain the warning?
Mhm… Well, that does reduce the testcase to this code:
;;; -*- lexical-binding: t -*-
(progn
(defun hello()
(print "hello"))
(hello))
So the function is defined in the same visibility scope as where it's used, right
before its use, but byte-compiler apparently doesn't see that.
This bug report was last modified 1 year and 125 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.