From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#67196: M-: uses a wrong value of debug-on-error when it is nil. Date: Fri, 24 Nov 2023 22:21:27 +0000 Message-ID: References: <83a5rfq6i2.fsf@gnu.org> <83ttpbdm2f.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14030"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 67196@debbugs.gnu.org, acm@muc.de, Eli Zaretskii To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 24 23:22:25 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 1r6eZ7-0003Ws-2C for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 24 Nov 2023 23:22:25 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r6eYi-0003K1-HM; Fri, 24 Nov 2023 17:22:00 -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 1r6eYg-0003JY-Lt for bug-gnu-emacs@gnu.org; Fri, 24 Nov 2023 17:21:58 -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 1r6eYg-0005Xh-Dp for bug-gnu-emacs@gnu.org; Fri, 24 Nov 2023 17:21:58 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r6eYk-00084q-MI for bug-gnu-emacs@gnu.org; Fri, 24 Nov 2023 17:22:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 24 Nov 2023 22:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67196 X-GNU-PR-Package: emacs Original-Received: via spool by 67196-submit@debbugs.gnu.org id=B67196.170086450230983 (code B ref 67196); Fri, 24 Nov 2023 22:22:02 +0000 Original-Received: (at 67196) by debbugs.gnu.org; 24 Nov 2023 22:21:42 +0000 Original-Received: from localhost ([127.0.0.1]:37416 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6eYQ-00083e-Dx for submit@debbugs.gnu.org; Fri, 24 Nov 2023 17:21:42 -0500 Original-Received: from mail.muc.de ([193.149.48.3]:25348) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6eYM-00083H-D5 for 67196@debbugs.gnu.org; Fri, 24 Nov 2023 17:21:40 -0500 Original-Received: (qmail 66504 invoked by uid 3782); 24 Nov 2023 23:21:27 +0100 Original-Received: from acm.muc.de (pd953a757.dip0.t-ipconnect.de [217.83.167.87]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 24 Nov 2023 23:21:26 +0100 Original-Received: (qmail 1894 invoked by uid 1000); 24 Nov 2023 22:21:27 -0000 Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de 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:274897 Archived-At: Hello, Stefan. On Fri, Nov 24, 2023 at 16:25:11 -0500, Stefan Monnier wrote: > > + (let* ((debug-from--eval-expression eval-expression-debug-on-error) > > + (result (values--store-value > > + (eval (let ((lexical-binding t)) (macroexpand-all exp)) t))) > > + (print-length (unless no-truncate eval-expression-print-length)) > > + (print-level (unless no-truncate eval-expression-print-level)) > > + (eval-expression-print-maximum-character char-print-limit) > > + (deactivate-mark) > > + (out (if insert-value (current-buffer) t))) > > + (prog1 > > + (prin1 result out) > > + (let ((str (and char-print-limit > > + (eval-expression-print-format result)))) > > + (when str (princ str out)))))) > So you kicked the can a bit further down the road. > The next bug report will be that `M-: debug-from--eval-expression` does > not return the expected value. Not at all. debug-from--eval-expression is a purely internal variable, unlike debug-on-error which is intended for user use. It is bound in exactly one place, and tested in exactly one place. Anybody reporting such a "bug" would legitimately get the reply "not a bug". > FWIW, the other way I came up to circumvent the problem is to test the > shape of the expression to evaluate and only use > `eval-expression-debug-on-error` when the expression is not a mere > symbol (for which the backtrace would presumably not be interesting anyway). > But then we get the weird situation where `M-x debug-on-error` can > return nil but `M-x (list debug-on-error ...)` returns a list that > starts with t. [ By M-x, I assume you're meaning M-:.] Yes. Such a patch wouldn't fix the bug. The root of the bug is trying to make debug-on-error do two different contradictory jobs, as we've already discussed. To fix this, you've either got to decide not to do one of these jobs at all, or introduce a new variable. My patch does the second of these. > I think I'd rather keep the current code, whose semantics is > actually simpler. No. My patch fixes the bug, by introducing a separate variable to do one of the two jobs that debug-on-error is currently trying to do. This is a simplification. As a side effect, eval-expression has been reduced from 59 to 44 lines; not counting the doc string this is a reduction of around 50%. For what it's worth, I lost about 10 hours of time trying to debug a situation where I wasn't getting a backtrace, despite debug-on-error being t. The problem was that d-o-e wasn't t at all, it was nil. M-: had been lying. > Stefan -- Alan Mackenzie (Nuremberg, Germany).