From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Konstantin Kharlamov 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 07:00:40 +0300 Message-ID: <4380470ad6bbde9eb8b72135a039da5d218df8e9.camel@yandex.ru> 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> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12092"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.50.3 Cc: 69120@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Feb 15 05:02:02 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 1raSwk-0002uc-4Z for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 15 Feb 2024 05:02:02 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raSwU-0003Sr-Ac; Wed, 14 Feb 2024 23:01:46 -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 1raSwS-0003SV-7n for bug-gnu-emacs@gnu.org; Wed, 14 Feb 2024 23:01: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 1raSwR-0001JK-Vr for bug-gnu-emacs@gnu.org; Wed, 14 Feb 2024 23:01:43 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1raSwk-0007IY-Bt for bug-gnu-emacs@gnu.org; Wed, 14 Feb 2024 23:02:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Konstantin Kharlamov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 15 Feb 2024 04:02: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.170796966327975 (code B ref 69120); Thu, 15 Feb 2024 04:02:02 +0000 Original-Received: (at 69120) by debbugs.gnu.org; 15 Feb 2024 04:01:03 +0000 Original-Received: from localhost ([127.0.0.1]:53723 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1raSvm-0007H9-VH for submit@debbugs.gnu.org; Wed, 14 Feb 2024 23:01:03 -0500 Original-Received: from forward501a.mail.yandex.net ([178.154.239.81]:53238) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1raSvl-0007Gb-Mi for 69120@debbugs.gnu.org; Wed, 14 Feb 2024 23:01:02 -0500 Original-Received: from mail-nwsmtp-smtp-production-main-55.vla.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-55.vla.yp-c.yandex.net [IPv6:2a02:6b8:c0d:230c:0:640:f8e:0]) by forward501a.mail.yandex.net (Yandex) with ESMTPS id 91D1661DFE; Thu, 15 Feb 2024 07:00:41 +0300 (MSK) Original-Received: by mail-nwsmtp-smtp-production-main-55.vla.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id e0gwD348VCg0-8dChsj3x; Thu, 15 Feb 2024 07:00:41 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1707969641; bh=osE4XrpZCjTiXtxVbNgDLW/z9PuvnkmXRS5RKBagglc=; h=References:Date:In-Reply-To:Cc:To:From:Subject:Message-ID; b=izkINAWwU9bz+aVxJnF6cIFnaQFaju2XSOtxuiMYm9fvycq9AjOtLIJpphI/CwSoO AqxfVokbs94NQFZ7e0DjsHzgY+3nBuD8bQy/0ZzzC5aP+C5UpWZqwLdMBozqu0Xkbn c6kuqRCOeoRxqlR7VBOz0BePUtPCa+FGkw2uX7pc= Authentication-Results: mail-nwsmtp-smtp-production-main-55.vla.yp-c.yandex.net; dkim=pass header.i=@yandex.ru In-Reply-To: <5d0c0baa89e8fc0fe6fe9d4fdfbca72cf67d123e.camel@yandex.ru> 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:280037 Archived-At: 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=E2=80=A6 Well, that does reduce the testcase to this code: > >=20 > > =C2=A0=C2=A0=C2=A0 ;;; -*- lexical-binding: t -*- > > =C2=A0=C2=A0=C2=A0 (progn > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (defun hello() > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (print "hello")) > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (hello)) > >=20 > > 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. >=20 > Turns out this false-positive is even more common than I thought. >=20 > 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 =E2=80=A6)`, and the function is defined > inside the same `(defun =E2=80=A6)` as well. And it also triggers the sam= e > warning. In terms of minimal testcase: >=20 > =C2=A0=C2=A0 ;;; -*- lexical-binding: t -*- > =C2=A0=C2=A0 (defun foo () > =C2=A0=C2=A0=C2=A0=C2=A0 (defun hello() > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (print "hello")) > =C2=A0=C2=A0=C2=A0=C2=A0 (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`.