From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs 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 Message-ID: <86v86qw77z.fsf@gnu.org> References: <7f4f61be9fbdb5d07b9420d9b75a7ed9d1522744.camel@yandex.ru> <86eddfxe7d.fsf@gnu.org> <7aa4ac2b4eb557533d5b77b03b3ce2a74a674f21.camel@yandex.ru> <868r3nxc4u.fsf@gnu.org> <379435a543c0fb73d4f0ede0fd8c82b4134ec41d.camel@yandex.ru> <867cj7xaqe.fsf@gnu.org> <66ec2134f5cde69d417646dba07ec724f15af36d.camel@yandex.ru> <5d0c0baa89e8fc0fe6fe9d4fdfbca72cf67d123e.camel@yandex.ru> <4380470ad6bbde9eb8b72135a039da5d218df8e9.camel@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22444"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 69120@debbugs.gnu.org To: Konstantin Kharlamov , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Feb 15 07:51:52 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raVb6-0005fX-IU for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 15 Feb 2024 07:51:52 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raVaz-0005Rr-4v; Thu, 15 Feb 2024 01:51:45 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raVay-0005Ri-CV for bug-gnu-emacs@gnu.org; Thu, 15 Feb 2024 01:51:44 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raVay-0005qS-3z for bug-gnu-emacs@gnu.org; Thu, 15 Feb 2024 01:51:44 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1raVbG-0003Zn-HY for bug-gnu-emacs@gnu.org; Thu, 15 Feb 2024 01:52:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 15 Feb 2024 06:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69120 X-GNU-PR-Package: emacs Original-Received: via spool by 69120-submit@debbugs.gnu.org id=B69120.170797991713736 (code B ref 69120); Thu, 15 Feb 2024 06:52:02 +0000 Original-Received: (at 69120) by debbugs.gnu.org; 15 Feb 2024 06:51:57 +0000 Original-Received: from localhost ([127.0.0.1]:53869 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1raVbB-0003ZT-73 for submit@debbugs.gnu.org; Thu, 15 Feb 2024 01:51:57 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:50186) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1raVb9-0003ZB-3P for 69120@debbugs.gnu.org; Thu, 15 Feb 2024 01:51:55 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raVal-0005mk-8d; Thu, 15 Feb 2024 01:51:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=sZQuX39XPmihSnghQvL7WDr4z8YvxJjju3OeRMOZi0c=; b=oTAJ5U3Px9XP+A+Jj3Dh y9ufxQnfnHXf4q8ns1YTbpXZtIXzmsx5lgpFD3GQiBg0WIcZVO4ZNaacSOmFtdKVpB5B+GwOukQJl jr8yCIxNhwYCv69M/W5LcIb9wFC1H1/lqORkisTVuv/m87Mb2mr70EEzFhoedU/l+x5pRHUYVWkDx VIYQETvc9H06uk6vJ6rcxMoET8B9WDQVKr/0nItRMXA1uydnDD7pxTy9e4PIl2kUIIduP3Kl2LWW+ K0TVTWQ1LwVrrsfC8NESJ1lqaJIGj2tFWg+PSwkR/fptn5CvgTz0dUBHfjgL+eAkZLUooz0hkg9YK 7i1zAhbw5OYDYg==; In-Reply-To: <4380470ad6bbde9eb8b72135a039da5d218df8e9.camel@yandex.ru> (message from Konstantin Kharlamov on Thu, 15 Feb 2024 07:00:40 +0300) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:280041 Archived-At: > From: Konstantin Kharlamov > 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.