From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#65344: 28.2; Unable to Edebug cl-flet form which uses argument destructuring Date: Sat, 02 Sep 2023 15:27:51 -0400 Message-ID: References: <5184DD53-F121-405D-AEE9-6E72E17127EA@gmail.com> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17109"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Michael Heerdegen , brandon.irizarry@gmail.com, Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= , Michael Albinus , 65344@debbugs.gnu.org To: Gerd =?UTF-8?Q?M=C3=B6llmann?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Sep 02 21:29:11 2023 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 1qcWIw-0004Fr-Qy for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 02 Sep 2023 21:29:11 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcWIf-00040T-IA; Sat, 02 Sep 2023 15:28:53 -0400 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 1qcWIe-00040J-H2 for bug-gnu-emacs@gnu.org; Sat, 02 Sep 2023 15:28:52 -0400 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 1qcWIe-00073z-8s for bug-gnu-emacs@gnu.org; Sat, 02 Sep 2023 15:28:52 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qcWIo-0005ZW-2i for bug-gnu-emacs@gnu.org; Sat, 02 Sep 2023 15:29:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 02 Sep 2023 19:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65344 X-GNU-PR-Package: emacs Original-Received: via spool by 65344-submit@debbugs.gnu.org id=B65344.169368289221359 (code B ref 65344); Sat, 02 Sep 2023 19:29:02 +0000 Original-Received: (at 65344) by debbugs.gnu.org; 2 Sep 2023 19:28:12 +0000 Original-Received: from localhost ([127.0.0.1]:38707 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcWHz-0005YR-Li for submit@debbugs.gnu.org; Sat, 02 Sep 2023 15:28:11 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:12551) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcWHy-0005YF-0h for 65344@debbugs.gnu.org; Sat, 02 Sep 2023 15:28:11 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 1D96E4415D8; Sat, 2 Sep 2023 15:27:54 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1693682872; bh=iGVpLDQ5sAhM+PElSuxsU7Ii6+7dYUa4yus2+StkW/c=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=B2rmWfuURrugrYXBojWdejKY5LfykWEXw2bNvi8WGdT0rSZba374fkcCYPv5NDY/d S4TLX9kdLF5sehJUw2hng9ywf6OtCHsCZ5xwa9JYO02iqDTBSJjBI7JpsuC1hGqUVX rc889WFP5sKGVmqSBKAo+z2tf+t8PxnN4GB5jkv3W8w7JmCKIYfR9b2VZgl1jwVPnt pOoVFXwM4fHig8NTm7M7o6pazAXjjFNBz2vRUKNA5UFNIvGsDh22ujRBZieoj38Op3 wugPeJkONQo+i8fyoY8T9BaXUJDxGJaH0cBylYtjigATWH14ITqygPMvhLNYdEVXXC T1TbfvyT543ig== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 9D84A4414A2; Sat, 2 Sep 2023 15:27:52 -0400 (EDT) Original-Received: from pastel (unknown [45.72.228.218]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 670C312026A; Sat, 2 Sep 2023 15:27:52 -0400 (EDT) In-Reply-To: (Stefan Monnier's message of "Sat, 02 Sep 2023 13:04:57 -0400") 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:269049 Archived-At: >> In this case, the code for F will be run in the body of the >> flet. Doesn't that qualify as being run later, as you describe above, >> ignoring the "non-instrumented" part, maybe? > > No, in the above case the `def-form` is > > (lambda () (list 1 2)) > > which will be "run" right when we enter the `cl-flet` ("run" is an > exaggeration here since this lambda is a constant so it'll just > self-evaluate) and not when `f` is called. More specifically, the annotated code of (defun sm-foo (x) (cl-flet ((f (prog1 (lambda (y) (+ x y)) 0))) (f 5))) stored into (symbol-function 'sm-foo) now looks like: (closure (t) (x) (edebug-enter 'sm-foo (list x) #'(lambda nil :closure-dont-trim-context (edebug-after (edebug-before 0) 3 (let* ((--cl-f-- (edebug-enter 'f@cl-flet@4 nil #'(lambda nil :closure-dont-trim-context (edebug-after (edebug-before 0) 1 (prog1 #'(lambda (y) (edebug-enter 'edebug-anon5 (list y) #'(lambda nil :closure-dont-trim-context (edebug-after (edebug-before 0) 3 (+ (edebug-after 0 1 x) (edebug-after 0 2 y)))))) 0)))))) (progn (edebug-after (edebug-before 1) 2 (funcall --cl-f-- 5)))))))) As you can see for `sm-foo` itself, the (edebug-enter 'sm-foo (list x) #'(lambda nil :closure-dont-trim-context is (correctly) placed at the very beginning of the body of the function, so that code coverage can track whether `sm-foo` was called or not. In contrast the (edebug-enter 'f@cl-flet@4 nil #'(lambda nil :closure-dont-trim-context is placed around the code which will compute&return the `f@cl-flet@4` function, but not inside its body, which instead gets (edebug-enter 'edebug-anon5 (list y) #'(lambda nil :closure-dont-trim-context It's actually difficult (and in general impossible) to associate the name `f@cl-flet@4` with the corresponding `lambda`, so the use of `edebug-anon5` is largely unavoidable here. But making the code-coverage say that `f@cl-flet@4` is called just because we computed that function (regardless if it's been called) is a problem. Stefan