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#66912: With `require', the byte compiler reports the wrong file for errors. Date: Wed, 30 Oct 2024 21:52:13 +0000 Message-ID: References: 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="14866"; mail-complaints-to="usenet@ciao.gmane.io" Cc: acm@muc.de, 66912@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Oct 30 22:53:24 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 1t6Gd1-0003iJ-V8 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 30 Oct 2024 22:53:23 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6Gcj-0006U3-R9; Wed, 30 Oct 2024 17:53:05 -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 1t6Gci-0006Tm-3V for bug-gnu-emacs@gnu.org; Wed, 30 Oct 2024 17:53:04 -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 1t6Gcg-0002I7-Nx for bug-gnu-emacs@gnu.org; Wed, 30 Oct 2024 17:53:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=From:In-Reply-To:MIME-Version:References:Date:To:Subject; bh=e6fpbiG1z11yMdz6oHvfuNOUWhjK0VQ9RV+fyTzOPO4=; b=D9neGBkylzS7n9ZbIFEXrZL1MxpFwt1om1VkMUWqzdAatn7o5KTfE+yq6BXgM3qAKWyELnJ+5xCTasjlZelj+GnceL909CyuL83531IW2SkZsmIPx+PKK9KiTzqZqAJnU9N8Xx60D8QZkV/AKyoAM6rYxTFpDGQ3l15CTKOa5wXRs2UugfdpvY8R/a0rHAz57txKHTapt7s6kp4pDBpfsjA27YsEHJ9sTyNJl3DvoZxjXc9i5dXJ+f82CRZqURFcQiCBiFT92HUZyrrRK5eL76rcGwIWCnl5CS6czCW/4anKX4vLuQAu+1jbevvIRagGCC5JimfAgPPo6mHn3GVrbA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t6Gcg-0002J6-IT for bug-gnu-emacs@gnu.org; Wed, 30 Oct 2024 17:53:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 30 Oct 2024 21:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66912 X-GNU-PR-Package: emacs Original-Received: via spool by 66912-submit@debbugs.gnu.org id=B66912.17303251458841 (code B ref 66912); Wed, 30 Oct 2024 21:53:02 +0000 Original-Received: (at 66912) by debbugs.gnu.org; 30 Oct 2024 21:52:25 +0000 Original-Received: from localhost ([127.0.0.1]:37739 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t6Gc5-0002IX-3E for submit@debbugs.gnu.org; Wed, 30 Oct 2024 17:52:25 -0400 Original-Received: from mail.muc.de ([193.149.48.3]:59143) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t6Gc2-0002IL-1U for 66912@debbugs.gnu.org; Wed, 30 Oct 2024 17:52:22 -0400 Original-Received: (qmail 54852 invoked by uid 3782); 30 Oct 2024 22:52:13 +0100 Original-Received: from muc.de (pd953a184.dip0.t-ipconnect.de [217.83.161.132]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Wed, 30 Oct 2024 22:52:13 +0100 Original-Received: (qmail 15004 invoked by uid 1000); 30 Oct 2024 21:52:13 -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:294583 Archived-At: Hello, Stefan. On Wed, Oct 30, 2024 at 15:33:04 -0400, Stefan Monnier wrote: > > year, in place of the current error output > > test-byte-compile-errors.el:2:11: Error: Wrong type argument: listp, baz > > the following line would appear: > > test-byte-compile-errors.el:2:11: While loading "test-byte-compile-errors-2.el" Error: Wrong type argument: listp, baz > I can definitely live with this syntax, but maybe we should use > something more like what GCC uses (e.g. for errors in #included files) > which puts the "While loading" info on separate lines. I thought about that, but seeing as how only one message at a time is visible in the message area, we'd probably want to output one message with embedded LFs, rather than several consecutive "While loading ..."s. > > This could surely be achieved with something like the following in Fload: > > (handler-bind ((lambda (err) > > (signal (car err) > > (combine-error-info "While loading " file > > (cdr err))))) > > readevalloop (Qget_file_char, &input, hist_file_name, > > 0, Qnil, Qnil, Qnil, Qnil);) > That was my thinking as well (tho see below). > > (where, obviously, the details need to be worked out). It would need > > augmenting with handling for (eq debug-on-error t), and probably a few > > other things, too. > `combine-error-info` is a bit problematic because we don't have clear > rules about the content of (cdr err), other than the fact that it should > be a list (tho we don't even enforce that very much). > Most likely we could append elements to that list, but we'd have to > worry about interactions with other libraries wanting to do similar > things. Do other libraries actually do such things? > So I was thinking that we should go instead with: > (handler-bind ((error (lambda (err) > (push file (gethash err our-table-of-error-source))))) > readevalloop (Qget_file_char, &input, hist_file_name, > 0, Qnil, Qnil, Qnil, Qnil);) > Where `our-table-of-error-source` would be a weak eq-hashtable. Do we need a hash table when it's only going to have a few elements at any time? `require's rarely go more than 5 or 6 deep. Why not just have a simple dynamically bound list? Or have I misunderstood what you mean? > Emacs Lisp guarantees that the `err` we get here will be the exact same > object that any subsequent `condition-case` will get when it finally > handles the error so that it can use `gethash` to fetch our > side information. > Note that we don't `signal` the error again, instead we let the error > handling code propagate it further, which is what `handler-bind` does > when the handler returns normally (which should also eliminate the > possible problems of interaction with `debug-on-error`). The reason I suggested a signal call was so that the error information in the successive ERRs would accumulate, rather than just being the fixed ERR from the initial error. And I think any call to the debugger on account of debug-on-error should be in the innermost recursive `require', where the error is actually signalled, so as to be of maximum use to the person debugging it. > Stefan -- Alan Mackenzie (Nuremberg, Germany).