From mboxrd@z Thu Jan 1 00:00:00 1970
Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail
From: Philipp
Newsgroups: gmane.emacs.bugs
Subject: bug#41988: 28.0.50;
Edebug unconditionally instruments definitions with &define specs
Date: Sat, 10 Apr 2021 17:07:48 +0200
Message-ID:
References:
<6D19F14E-0133-4751-B0BD-EC2A73C1D21F@gmail.com>
<3619E155-8F06-4F8F-B239-121ED3D164A8@gmail.com>
Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\))
Content-Type: multipart/mixed;
boundary="Apple-Mail=_0FA6AC35-A661-4A8B-A5A4-E683CEB3EE33"
Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214";
logging-data="33126"; mail-complaints-to="usenet@ciao.gmane.io"
Cc: 41988@debbugs.gnu.org
To: Stefan Monnier
Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 10 17:08:11 2021
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 1lVFDW-0008WV-Mu
for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 10 Apr 2021 17:08:10 +0200
Original-Received: from localhost ([::1]:59574 helo=lists1p.gnu.org)
by lists.gnu.org with esmtp (Exim 4.90_1)
(envelope-from )
id 1lVFDV-0004H0-9j
for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 10 Apr 2021 11:08:09 -0400
Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45728)
by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.90_1) (envelope-from )
id 1lVFDO-0004Gs-CE
for bug-gnu-emacs@gnu.org; Sat, 10 Apr 2021 11:08:02 -0400
Original-Received: from debbugs.gnu.org ([209.51.188.43]:41492)
by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
(Exim 4.90_1) (envelope-from )
id 1lVFDO-0006Mf-5M
for bug-gnu-emacs@gnu.org; Sat, 10 Apr 2021 11:08:02 -0400
Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
(envelope-from ) id 1lVFDN-0000b7-W3
for bug-gnu-emacs@gnu.org; Sat, 10 Apr 2021 11:08:02 -0400
X-Loop: help-debbugs@gnu.org
Resent-From: Philipp
Original-Sender: "Debbugs-submit"
Resent-CC: bug-gnu-emacs@gnu.org
Resent-Date: Sat, 10 Apr 2021 15:08:01 +0000
Resent-Message-ID:
Resent-Sender: help-debbugs@gnu.org
X-GNU-PR-Message: followup 41988
X-GNU-PR-Package: emacs
Original-Received: via spool by 41988-submit@debbugs.gnu.org id=B41988.16180672782287
(code B ref 41988); Sat, 10 Apr 2021 15:08:01 +0000
Original-Received: (at 41988) by debbugs.gnu.org; 10 Apr 2021 15:07:58 +0000
Original-Received: from localhost ([127.0.0.1]:53038 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from )
id 1lVFDJ-0000ap-T9
for submit@debbugs.gnu.org; Sat, 10 Apr 2021 11:07:58 -0400
Original-Received: from mail-wm1-f43.google.com ([209.85.128.43]:37668)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from ) id 1lVFDH-0000aZ-KG
for 41988@debbugs.gnu.org; Sat, 10 Apr 2021 11:07:56 -0400
Original-Received: by mail-wm1-f43.google.com with SMTP id
g66-20020a1c39450000b0290125d187ba22so3942438wma.2
for <41988@debbugs.gnu.org>; Sat, 10 Apr 2021 08:07:55 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
h=from:message-id:mime-version:subject:date:in-reply-to:cc:to
:references; bh=VKhYDmh4zFGMPNMDL4yIYUbG84J+HjHt0euao4Mt5oI=;
b=VXbt4tVptlin+Gr+r/mdCbzfWEsZHa6ZXTvOCR0cSUHf9689rvVZAQX4tkOegU4k78
TA3E/pSRybFuTpP9rdzJG1oH+FtdGGZJ/94aw9Mdjgd/wK2y5v2TzRZlOSzLQb5WaQoB
gPHGPNK2ZpXAPgi3bMDBQDwDSeTMq6qmNjHjErzK3XK4hN8TyT+9Ub8l/vmoMzw5i3Yh
8braU12+oXWUlMNvPErD9UfkxvQSNKiCCB92xoG5Y6Gc8Tc8pUAlBLw2Bqw97p6TAfGj
ASo93QzA4kBMuPZtbQXMaVGYl0GE9CUsLPGCn/u7JVXR0Q3a1iuVubvygbAcPbdavw8d
XiiQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:from:message-id:mime-version:subject:date
:in-reply-to:cc:to:references;
bh=VKhYDmh4zFGMPNMDL4yIYUbG84J+HjHt0euao4Mt5oI=;
b=gvM9mL5kvgtE3OZHb6CzwLVSCafHOBDyio9upOUUS4W6ZKatYmMtN2xAxiuTpiWdxB
YCoVpaJfmdhGSgDeXHGE9MyWSJl53UWUpkRsJ82mNJZXd8eYQGm0lcKgBqQUe1YLyqsf
uGAqV878Pc+/URKT3Peu1b2ojd9drPMqmlRXg3xjk7p+iB9TijEbXL206I7ss9hnSbHD
Bd5iPHbrgmR0I22e0m351ioPFKMeQcGn3rkhflPrujh4zjBB3IPXg7h0gvXcJdEWOInw
ABwQWUO3ckMkJ4nrnh61XvUAg/bmNXeGnpUFufyWW7TuIktiIj+37//rWpNW1B3Fa5B2
9apQ==
X-Gm-Message-State: AOAM5308IzHpRYghhaM9jtFscdXoqy07JKA5ZiE1OHkOJJXWLdQh8udc
O6pA/N71tpmz/K9mf979ET4=
X-Google-Smtp-Source: ABdhPJyR6R8nj7atYPhaMLgNTy2Mt8wyRmAtagQudQRxRxb0XUslPMI4BPHalAbpxScgxy98D950qQ==
X-Received: by 2002:a7b:cbc4:: with SMTP id n4mr19022582wmi.153.1618067269773;
Sat, 10 Apr 2021 08:07:49 -0700 (PDT)
Original-Received: from philipps-macbook-pro.fritz.box (p57997a31.dip0.t-ipconnect.de.
[87.153.122.49])
by smtp.gmail.com with ESMTPSA id w22sm8145629wmc.13.2021.04.10.08.07.48
(version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
Sat, 10 Apr 2021 08:07:49 -0700 (PDT)
In-Reply-To:
X-Mailer: Apple Mail (2.3654.60.0.2.21)
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"
Xref: news.gmane.io gmane.emacs.bugs:203798
Archived-At:
--Apple-Mail=_0FA6AC35-A661-4A8B-A5A4-E683CEB3EE33
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=us-ascii
> Am 05.04.2021 um 16:32 schrieb Philipp Stephani =
:
>=20
>>>>> so I think it would be reasonable to prevent. We already
>>>>> disable backtracking for literal symbols, and I think forms that =
require
>>>>> multiple &define forms with backtracking should be exceedingly =
rare and can
>>>>> be rewritten as you did with cl-flet.
>>>> Emitting a warning would be much more helpful than just silently
>>>> "cut"ting the backtracking.
>>> A gate isn't silent, it would cause a hard error in this case.
>>=20
>> What I meant is that a gate would just make the old cl-flet spec fail =
in
>> most cases, with no explanation why that spec now fails even though =
it
>> worked in the past.
>=20
> Yes, we'd need to at least announce the change in NEWS as an
> incompatible Lisp change. However, I think overall that's still better
> than the current situation: with your fix to cl-flet the problematic
> constructs shouldn't occur any more in the Emacs codebase, and I
> wouldn't expect such constructs to be very frequent "in the wild", so
> the overall breakage would be very small, and if it can avoid
> similarly subtle bugs then I think it's warranted.
Here's a patch.
--Apple-Mail=_0FA6AC35-A661-4A8B-A5A4-E683CEB3EE33
Content-Disposition: attachment;
filename=0001-Edebug-Disable-backtracking-when-hitting-a-define-ke.patch
Content-Type: application/octet-stream;
x-unix-mode=0644;
name="0001-Edebug-Disable-backtracking-when-hitting-a-define-ke.patch"
Content-Transfer-Encoding: quoted-printable
=46rom=209e2183edea41adf275f057a75232ea0b2c51e726=20Mon=20Sep=2017=20=
00:00:00=202001=0AFrom:=20Philipp=20Stephani=20=0ADate:=20=
Thu,=2018=20Mar=202021=2012:40:08=20+0100=0ASubject:=20[PATCH]=20Edebug:=20=
Disable=20backtracking=20when=20hitting=20a=20&define=20keyword.=0A=0A=
Edebug=20doesn't=20deal=20well=20with=20backtracking=20out=20of=20=
definitions,=20see=0ABug#41988.=20=20Rather=20than=20trying=20to=20=
support=20this=20rare=20situation=20(e.g.=20by=0Aimplementing=20a=20=
multipass=20parser),=20prevent=20it=20by=20adding=20an=20implicit=0A=
gate.=0A=0A*=20lisp/emacs-lisp/edebug.el=20(edebug--match-&-spec-op):=20=
Disable=0Abacktracking=20when=20hitting=20a=20&define=20keyword.=0A=0A*=20=
test/lisp/emacs-lisp/edebug-tests.el=0A(edebug-tests-duplicate-&define):=20=
New=20unit=20test.=0A(edebug-tests--duplicate-&define):=20New=20helper=20=
macro.=0A=0A*=20doc/lispref/edebug.texi=20(Backtracking):=20Mention=20=
&define=20in=20the=20list=0Aof=20constructs=20that=20disable=20=
backtracking.=0A=0A*=20etc/NEWS:=20Document=20new=20behavior.=0A---=0A=20=
doc/lispref/edebug.texi=20=20=20=20=20=20=20=20=20=20=20=20=20=20|=2010=20=
+++++-----=0A=20etc/NEWS=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20|=20=203=20+++=0A=20=
lisp/emacs-lisp/edebug.el=20=20=20=20=20=20=20=20=20=20=20=20|=2018=20=
++++++++++--------=0A=20test/lisp/emacs-lisp/edebug-tests.el=20|=2025=20=
+++++++++++++++++++++++++=0A=204=20files=20changed,=2043=20=
insertions(+),=2013=20deletions(-)=0A=0Adiff=20--git=20=
a/doc/lispref/edebug.texi=20b/doc/lispref/edebug.texi=0Aindex=20=
8942f55aff..323130f237=20100644=0A---=20a/doc/lispref/edebug.texi=0A+++=20=
b/doc/lispref/edebug.texi=0A@@=20-1510,11=20+1510,11=20@@=20Backtracking=0A=
=20must=20be=20in=20the=20form=20itself=20rather=20than=20at=20a=20=
higher=20level.=0A=20=0A=20Backtracking=20is=20also=20disabled=20after=20=
successfully=20matching=20a=20quoted=0A-symbol=20or=20string=20=
specification,=20since=20this=20usually=20indicates=20a=0A-recognized=20=
construct.=20=20But=20if=20you=20have=20a=20set=20of=20alternative=20=
constructs=20that=0A-all=20begin=20with=20the=20same=20symbol,=20you=20=
can=20usually=20work=20around=20this=0A-constraint=20by=20factoring=20=
the=20symbol=20out=20of=20the=20alternatives,=20e.g.,=0A-@code{["foo"=20=
&or=20[first=20case]=20[second=20case]=20...]}.=0A+symbol,=20string=20=
specification,=20or=20@code{&define}=20keyword,=20since=20this=0A=
+usually=20indicates=20a=20recognized=20construct.=20=20But=20if=20you=20=
have=20a=20set=20of=0A+alternative=20constructs=20that=20all=20begin=20=
with=20the=20same=20symbol,=20you=20can=0A+usually=20work=20around=20=
this=20constraint=20by=20factoring=20the=20symbol=20out=20of=20the=0A=
+alternatives,=20e.g.,=20@code{["foo"=20&or=20[first=20case]=20[second=20=
case]=20...]}.=0A=20=0A=20Most=20needs=20are=20satisfied=20by=20these=20=
two=20ways=20that=20backtracking=20is=0A=20automatically=20disabled,=20=
but=20occasionally=20it=20is=20useful=20to=20explicitly=0Adiff=20--git=20=
a/etc/NEWS=20b/etc/NEWS=0Aindex=20a0f05d8cf1..9ae3740482=20100644=0A---=20=
a/etc/NEWS=0A+++=20b/etc/NEWS=0A@@=20-2524,6=20+2524,9=20@@=20back=20in=20=
Emacs=2023.1.=20=20The=20affected=20functions=20are:=20'make-obsolete',=0A=
=20=0A=20**=20The=20'values'=20variable=20is=20now=20obsolete.=0A=20=0A=
+**=20The=20'&define'=20keyword=20in=20an=20Edebug=20specification=20now=20=
disables=0A+backtracking.=0A+=0A=20=0C=0A=20*=20Lisp=20Changes=20in=20=
Emacs=2028.1=0A=20=0Adiff=20--git=20a/lisp/emacs-lisp/edebug.el=20=
b/lisp/emacs-lisp/edebug.el=0Aindex=20f1455ffe73..365bc74874=20100644=0A=
---=20a/lisp/emacs-lisp/edebug.el=0A+++=20b/lisp/emacs-lisp/edebug.el=0A=
@@=20-1942,14=20+1942,16=20@@=20edebug--match-&-spec-op=0A=20=20=20;;=20=
Normally,=20&define=20is=20interpreted=20specially=20other=20places.=0A=20=
=20=20;;=20This=20should=20only=20be=20called=20inside=20of=20a=20spec=20=
list=20to=20match=20the=20remainder=0A=20=20=20;;=20of=20the=20current=20=
list.=20=20e.g.=20("lambda"=20&define=20args=20def-body)=0A-=20=20=20=
(edebug-make-form-wrapper=0A-=20=20=20=20cursor=0A-=20=20=20=20=
(edebug-before-offset=20cursor)=0A-=20=20=20=20;;=20Find=20the=20last=20=
offset=20in=20the=20list.=0A-=20=20=20=20(let=20((offsets=20=
(edebug-cursor-offsets=20cursor)))=0A-=20=20=20=20=20=20(while=20(consp=20=
offsets)=20(setq=20offsets=20(cdr=20offsets)))=0A-=20=20=20=20=20=20=
offsets)=0A-=20=20=20=20specs))=0A+=20=20(prog1=20=
(edebug-make-form-wrapper=0A+=20=20=20=20=20=20=20=20=20=20cursor=0A+=20=20=
=20=20=20=20=20=20=20=20(edebug-before-offset=20cursor)=0A+=20=20=20=20=20=
=20=20=20=20=20;;=20Find=20the=20last=20offset=20in=20the=20list.=0A+=20=20=
=20=20=20=20=20=20=20=20(let=20((offsets=20(edebug-cursor-offsets=20=
cursor)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20(while=20(consp=20=
offsets)=20(setq=20offsets=20(cdr=20offsets)))=0A+=20=20=20=20=20=20=20=20=
=20=20=20=20offsets)=0A+=20=20=20=20=20=20=20=20=20=20specs)=0A+=20=20=20=
=20;;=20Stop=20backtracking=20here=20(Bug#41988).=0A+=20=20=20=20(setq=20=
edebug-gate=20t)))=0A=20=0A=20(cl-defmethod=20edebug--match-&-spec-op=20=
((_=20(eql=20&name))=20cursor=20specs)=0A=20=20=20"Compute=20the=20name=20=
for=20`&name=20SPEC=20FUN`=20spec=20operator.=0Adiff=20--git=20=
a/test/lisp/emacs-lisp/edebug-tests.el=20=
b/test/lisp/emacs-lisp/edebug-tests.el=0Aindex=20dcb261c2eb..7d45432e57=20=
100644=0A---=20a/test/lisp/emacs-lisp/edebug-tests.el=0A+++=20=
b/test/lisp/emacs-lisp/edebug-tests.el=0A@@=20-1061,5=20+1061,30=20@@=20=
edebug-tests-duplicate-symbol-backtrack=0A=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20"edebug-anon10001"=0A=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
"edebug-tests-duplicate-symbol-backtrack"))))))=0A=20=0A+(defmacro=20=
edebug-tests--duplicate-&define=20(_arg)=0A+=20=20"Helper=20macro=20for=20=
the=20ERT=20test=20`edebug-tests-duplicate-&define'.=0A+The=20Edebug=20=
specification=20is=20similar=20to=20the=20one=20used=20by=20`cl-flet'=0A=
+previously;=20see=20Bug#41988."=0A+=20=20(declare=20(debug=20(&or=20=
(&define=20name=20function-form)=20(defun)))))=0A+=0A+(ert-deftest=20=
edebug-tests-duplicate-&define=20()=0A+=20=20"Check=20that=20Edebug=20=
doesn't=20backtrack=20out=20of=20`&define'=20forms.=0A+This=20avoids=20=
potential=20duplicate=20definitions=20(Bug#41988)."=0A+=20=20=
(with-temp-buffer=0A+=20=20=20=20(print=20'(defun=20=
edebug-tests-duplicate-&define=20()=0A+=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20(edebug-tests--duplicate-&define=0A+=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20(edebug-tests-duplicate-&define-inner=20()=20nil)))=0A+=20=20=
=20=20=20=20=20=20=20=20=20(current-buffer))=0A+=20=20=20=20(let*=20=
((edebug-all-defs=20t)=0A+=20=20=20=20=20=20=20=20=20=20=20=
(edebug-initial-mode=20'Go-nonstop)=0A+=20=20=20=20=20=20=20=20=20=20=20=
(instrumented-names=20())=0A+=20=20=20=20=20=20=20=20=20=20=20=
(edebug-new-definition-function=0A+=20=20=20=20=20=20=20=20=20=20=20=20=
(lambda=20(name)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20(when=20=
(memq=20name=20instrumented-names)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20(error=20"Duplicate=20definition=20of=20`%s'"=20name))=0A+=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20(push=20name=20=
instrumented-names)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
(edebug-new-definition=20name))))=0A+=20=20=20=20=20=20(should-error=20=
(eval-buffer)=20:type=20'invalid-read-syntax))))=0A+=0A=20(provide=20=
'edebug-tests)=0A=20;;;=20edebug-tests.el=20ends=20here=0A--=20=0A2.24.3=20=
(Apple=20Git-128)=0A=0A=
--Apple-Mail=_0FA6AC35-A661-4A8B-A5A4-E683CEB3EE33--