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#66912: With `require', the byte compiler reports the wrong file for errors. Date: Sat, 02 Nov 2024 10:51:46 -0400 Message-ID: References: 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="35649"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 66912@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Nov 02 15:52:21 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 1t7FUC-000967-Hn for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 02 Nov 2024 15:52:20 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t7FTv-0003P4-El; Sat, 02 Nov 2024 10:52:03 -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 1t7FTu-0003Ow-0t for bug-gnu-emacs@gnu.org; Sat, 02 Nov 2024 10:52:02 -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 1t7FTt-0000eW-Ob for bug-gnu-emacs@gnu.org; Sat, 02 Nov 2024 10:52:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=EZ3zYx112TqwIhST4JTWXydlZ1gylLvX87lXrhuNDFs=; b=h8pZzgMqU1xNi7LZKuLI079deBoFgT+6As8NwqQNJiFVSFSEQ6t18+9XNiiI33Bok2Xco/smVW1tUFg5z5oMXTDMqRa0rfa5eN2eGc/4pSoIYWWhyWOx3AjL91Poih6wfoCYQPeaxa5xOabjpkNRf8a+BqXprvvG1zXlJJJFvXAvj89yokqObZ4FFzDxujLpMW5dpEgAW3hhc0wcAe/ycBbhLuhdTTL88WXZFEPZEj2nPO7Ft4mqUfoOwOlSpzMFSwsnrVZbopwcGTFINuWEOdh7HSPDEldxQTM8AvCsOu3XR0YCj9HNsNRb3lHYtWy6zjF7veF9FYQnBnoaiAt2Ag==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t7FTt-0005hW-IG for bug-gnu-emacs@gnu.org; Sat, 02 Nov 2024 10:52:01 -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 Nov 2024 14:52:01 +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.173055911621905 (code B ref 66912); Sat, 02 Nov 2024 14:52:01 +0000 Original-Received: (at 66912) by debbugs.gnu.org; 2 Nov 2024 14:51:56 +0000 Original-Received: from localhost ([127.0.0.1]:53809 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t7FTo-0005hF-4m for submit@debbugs.gnu.org; Sat, 02 Nov 2024 10:51:56 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:44289) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t7FTm-0005h5-6a for 66912@debbugs.gnu.org; Sat, 02 Nov 2024 10:51:55 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 250C9802DA; Sat, 2 Nov 2024 10:51:48 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1730559107; bh=u+q32FUwbtSb9DuWpkg/yMsS9J7w51gkt2w0QrcijVA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=BFox1karsslsIBZBlRvhT1r19EZ38i6ZHFsOCW1HfVCpNMKuYIRd/jFd9LUq83sNF VdOHj+NPArE4/kplsEhAcZ3lY5RxMbyDr7Ht3857n6sDbDaW1EH2SONolkxhb+nbV6 lyH/kUREdNvE4OU0ycsUMXZhN0Be//so/Ewyfpc9RQEQG/gJjp1IMnQsbuGjsh3jfh 9xosAGEZm+SeSZ/i8YlTcNXWaiHsfAycMxqikBS01xNrW+g5wUWd/t/vgEJ4dYWQrO qXhXIL/TI2iXZU/3h8yNSdLHZdafKQZ3CKBFhSgIm0kp6tr0t069JXnmNceediy3ca iEHhYASoAe0Pg== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 0F9278053B; Sat, 2 Nov 2024 10:51:47 -0400 (EDT) Original-Received: from pastel (104-195-225-43.cpe.teksavvy.com [104.195.225.43]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id E1E59120342; Sat, 2 Nov 2024 10:51:46 -0400 (EDT) In-Reply-To: (Alan Mackenzie's message of "Sat, 2 Nov 2024 13:47:12 +0000") 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:294752 Archived-At: > I don't think we need either. In lread.c, there is already a static > variable Vloads_in_progress (which despite the name, is not visible in > Lisp). This variable is a stack of the file names currently being > loaded. We could surely just use this, and avoid code duplication. In that case we don't need `handler-bind` at all, and we just tack the info when we build the error object in `Fsignal`. But I don't think it would be correct in all cases: if file A loads file B which compiles file C which loads file D which signals an error we want the compiler error message to say "error in D loaded from C" and not "error in D loaded from C loaded from B loaded from A". With `handler-bind`s which add only the "current" file info, the error will be labeled only with the relevant info, i.e. the intervening loads between the `condition-case` (or `handler-bind`s) and the actual error. > I've been working out details in the last two or three days. I actually > think the handler should exit with a (throw 'exit t). That's because ... What/where would be the matching `catch`? I don't think the `handler-bind` we'd add to `load` should make assumptions about how/where the errors will be handled. >> I think I agree tho "be in the innermost recursive `require'" seems >> quite vague. But in any case the handlers of `handler-bind` are run >> before we unwind the stack (e.g. if your nesting looks like "require => >> require => error" the two handlers of your two `require`s will be run >> before we get to the debugger but the debugger will still show the full >> stack. Tho with your use of "resignaling" within the handlers, the >> stack will tend to be even "more full", with the two handlers nested >> and still active), so no matter how we do it, I think we will indeed get >> the behavior that I believe you describe. > > We should respect any user setting of debug-on-error to anything non-nil. > If non-nil, we should enter the debugger within the handler-bind's > handler, so as to have access to Emacs's state when the error occurred. I think we should do nothing special about `debug-on-error` and let it be handled by the existing code: it should "just work". > This mechanism is used in eval-expression. That's because `eval-expression` doesn't want to obey `debug-on-error`. > Also, this will prevent the byte compiler having (eq > byte-compile-debug nil) subverting the call of the debugger. > After all, when loading a file, we're not actually in the byte > compiler, so byte-compile-debug shouldn't have an effect. That would be nice. Not sure how easy to do it, OTOH. > On leaving the debugger after an error, we definitely don't want to > enter the debugger again for the next file on the loading stack. > Hence we should exit the handler with (throw 'exit t), or something > like it. If we're careful to preserve the `eq`ness of the error object, then the debugger will know it has already been triggered for this error. >> In any case, it should be easy to try out and change from one to the >> other with very local changes (I'd expect that the code of the handlers >> will be written in ELisp rather than C, right?). So either way is fine. > No, I think the handler code should be in C. The function handler-bind-1 > seems very clumsy for use from C code. It requires a function with no > parameters, so this would likely involve creating a closure in the C > code. This isn't good. I was talking about the code of the handlers. I.e. the one we push along with the HANDLER_BIND entry. I'd build the handler by calling to ELisp code (indeed, building closures from C is not good). Stefan