bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#69120: Spurious "function is not known to be defined" if defined in


From: Eli Zaretskii
Subject: bug#69120: Spurious "function is not known to be defined" if defined in `use-package` body
Date: Thu, 15 Feb 2024 08:51:28 +0200

> From: Konstantin Kharlamov <Hi-Angel@yandex.ru>
> Cc: 69120@debbugs.gnu.org
> Date: Thu, 15 Feb 2024 07:00:40 +0300
> 
> On Thu, 2024-02-15 at 06:57 +0300, Konstantin Kharlamov wrote:
> > On Wed, 2024-02-14 at 19:58 +0300, Konstantin Kharlamov wrote:
> > > 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.
> > 
> > Turns out this false-positive is even more common than I thought.
> > 
> > As upstream Emacs deprecated `defadvice`, I'm porting `lsp-mode`
> > plugin
> > to an `advice-add`. They use it as a debugging facility, and there's
> > an
> > "advicing" call inside a `(defun …)`, and the function is defined
> > inside the same `(defun …)` as well. And it also triggers the same
> > warning. In terms of minimal testcase:
> > 
> >    ;;; -*- lexical-binding: t -*-
> >    (defun foo ()
> >      (defun hello()
> >        (print "hello"))
> >      (hello))
> 
> An interesting fact: inserting a `(declare-function hello nil)` after a
> `defun` suppresses the warning. So I guess `defun` should work somehow
> similarly to `declare-function`.

Perhaps Stefan (CC'ed) will have some comments or advice.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]