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: Fri, 03 Nov 2023 12:09:03 -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="1931"; 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 Fri Nov 03 17:10:53 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 1qywl2-0000KF-Kq for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 03 Nov 2023 17:10:52 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qywkf-00081J-IC; Fri, 03 Nov 2023 12:10:29 -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 1qywkd-00080m-Jq for bug-gnu-emacs@gnu.org; Fri, 03 Nov 2023 12:10:27 -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 1qywkd-00072G-C2 for bug-gnu-emacs@gnu.org; Fri, 03 Nov 2023 12:10:27 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qywlC-0007Jk-JW for bug-gnu-emacs@gnu.org; Fri, 03 Nov 2023 12:11: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: Fri, 03 Nov 2023 16:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66912 X-GNU-PR-Package: emacs X-Debbugs-Original-Cc: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.169902781128052 (code B ref -1); Fri, 03 Nov 2023 16:11:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 3 Nov 2023 16:10:11 +0000 Original-Received: from localhost ([127.0.0.1]:59576 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qywkN-0007IO-0r for submit@debbugs.gnu.org; Fri, 03 Nov 2023 12:10:11 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:37754) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qywkL-0007Hn-6b for submit@debbugs.gnu.org; Fri, 03 Nov 2023 12:10:10 -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 1qywjW-0007cP-26 for bug-gnu-emacs@gnu.org; Fri, 03 Nov 2023 12:09:20 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qywjP-0006XS-VN for bug-gnu-emacs@gnu.org; Fri, 03 Nov 2023 12:09:16 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id DD69A80577; Fri, 3 Nov 2023 12:09:09 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1699027744; bh=dwkXb3n34kAF2r50vEbzBi/UOmVp09Ax3CINNEK2AgY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=gtC4/RlnuRymhZK8j/MNlMaNHMt492A50vA6WbBahZYGN/ipuqMMnBKBVgIu++Do0 rUvcTlUMcOaVWc8O/JgV5FA+leSC05nUIUJ74L2yWyVkTHeC1CQ/KUmSjUqKIauy7c /UMl2eYefM7YMboO2+uNwc1/wMzaGPaUT84uDknlCnnGgqsVlvxuWa+SKuPH98kF3l ZCfx6e6xUphDa1pE+b9ctNo+r+r7ncaMYBVHHSSbC1rBlSv7iY1jprE9KqVuIYpxQD l3+SiZI09EgBhdtM3BPcDHH2iv63hyZNzC5pPU4ti9rQLpZavkajz/UV/aaH4CxPwZ mEibCI876qBfw== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id CEB4480409; Fri, 3 Nov 2023 12:09:04 -0400 (EDT) Original-Received: from alfajor (unknown [23.233.149.155]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id A4E25120334; Fri, 3 Nov 2023 12:09:04 -0400 (EDT) In-Reply-To: (Alan Mackenzie's message of "Fri, 3 Nov 2023 11:32:41 +0000") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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:273713 Archived-At: > The pertinent error information is discarded by one of two > condition-cases in the macro displaying-byte-compile-warnings in > emacs-lisp/bytecomp.el. Kind of, yes. But the info available there is hard to use: basically at that point we could get the error message and the backtrace, which is what we get when we set `byte-compile-debug`. In the case where `byte-compile-debug` is not set, we don't really want to display a backtrace, so we'd have to "analyze" that backtrace to try and extract a useful error message from it, which is hard&brittle. > If these condition-case's are disabled (for example by spiking the > enclosing `if' forms) By "spiking" do you mean setting `byte-compile-debug`? > This appears to be a fundamental problem with condition-case. When an > error occurs, the stack gets unwound before the error handlers have a > chance to analyse it. [ This is going a bit on a tangent, but I think it would be good to add some support for something like Common-Lisp's `handler-bind`, i.e. error handlers that are run before unwinding the stack (so they can capture the stack trace as well as the value of dynbound vars at the moment the error occurs, for example). It would make it possible for ERT to refrain from activating `debug-on-error`, for example (which it does in order to capture the backtrace at the time of the error). ] I think for this specific problem being discussed (which is indeed a fairly common occurrence in my experience), the better solution is to change `load` so it adds the "context" (i.e. filename and ideally also the approximate file position info) to errors. [ This may require something like `handler-bind`. ] Stefan