From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Maxime Devos Newsgroups: gmane.lisp.guile.devel Subject: [PATCH] Print backtraces for syntax errors too. Date: Wed, 8 Feb 2023 16:59:05 +0100 Message-ID: <20230208155905.27194-1-maximedevos@telenet.be> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32111"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Maxime Devos To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Wed Feb 08 16:59:38 2023 Return-path: Envelope-to: guile-devel@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 1pPmrC-0008AU-74 for guile-devel@m.gmane-mx.org; Wed, 08 Feb 2023 16:59:38 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pPmqq-00087B-RY; Wed, 08 Feb 2023 10:59:16 -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 1pPmqp-00086u-UX for guile-devel@gnu.org; Wed, 08 Feb 2023 10:59:15 -0500 Original-Received: from albert.telenet-ops.be ([2a02:1800:110:4::f00:1a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pPmqn-0005Q3-Go for guile-devel@gnu.org; Wed, 08 Feb 2023 10:59:15 -0500 Original-Received: from localhost.localdomain ([IPv6:2a02:1811:8c09:9d00:5dba:d409:33f7:a16]) by albert.telenet-ops.be with bizsmtp id Jfz72900A20ykKC06fz7m1; Wed, 08 Feb 2023 16:59:07 +0100 X-Mailer: git-send-email 2.39.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r23; t=1675871947; bh=w07+0wxJhH3Pn0Xmusk4zrfb9PLMEwGqisIlcxaq4JE=; h=From:To:Cc:Subject:Date; b=HPfYoV8u6qm7zslR9MwePeu1+oycI8mFfUGguEEqVMuBHgxXER38ztUOPbheEs7NN UqCIiGqjyPhKSr8j+MLC/umsyrpDahz2p87/YbVXSqvMPfGyC8ZAZjdMwPsDQjL7It +gDi5ze7VW/aQU9sbnWje67FiDsQEkqiVSpnHAELjdfudLcigFcxymbCUXLU7qRCXs csRwZ01TMN1jx5krwnIf6ZhM6o4R2SraCnQVVh7f9q0YgYEiYNQE2Wix6+W4HQkUqC I71qUsb3BFYFXC4D/qmt/2SHQzKsPmQc8ZKzuIZbqN8sa7Yv1vLd7Y8EB7dvBq6oLU Nn/vMw+RcUBJg== Received-SPF: pass client-ip=2a02:1800:110:4::f00:1a; envelope-from=maximedevos@telenet.be; helo=albert.telenet-ops.be X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.devel:21693 Archived-At: For complicated macros, especially macros that are used correctly but have a bug in their implementation somewhere and use 'syntax-case' or 'syntax-rules' multiple times, it can be very convenient to know _which_ syntax-case or syntax-rules raised the syntax-error. E.g., I'm currently debugging some changes to a (non-Guile) macro, and I don't know what to make of the following -- the '#:getter . datum-type' isn't even present in the original code anywhere: ice-9/boot-9.scm:1685:16: In procedure raise-exception: Syntax error: unknown location: source expression failed to match any pattern in form (#:getter . datum-type) make: *** [Makefile:1333: gnu/gnunet/dht/client.go] Fout 1 As such, partially revert the following commit that does not give a rationale on how backtraces for syntax errors aren't helpful. commit e0c70a8b06db2f6d721556c23280471825c3830a Author: Andy Wingo Date: Fri Feb 11 15:16:25 2011 +0100 scm_handle_by_message uses scm_print_exception * libguile/throw.c (handler_message, should_print_backtrace): Use scm_print_exception. Add a helper function to determine when to print a backtrace; don't do so on read or syntax errors. --- libguile/throw.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libguile/throw.c b/libguile/throw.c index e837abe89..045759a00 100644 --- a/libguile/throw.c +++ b/libguile/throw.c @@ -359,8 +359,7 @@ should_print_backtrace (SCM tag, SCM stack) && scm_initialized_p /* It's generally not useful to print backtraces for errors reading or expanding code in these fallback catch statements. */ - && !scm_is_eq (tag, scm_from_latin1_symbol ("read-error")) - && !scm_is_eq (tag, scm_from_latin1_symbol ("syntax-error")); + && !scm_is_eq (tag, scm_from_latin1_symbol ("read-error")); } static void base-commit: 5b42f8c154906584455a4989038406c88b723cb0 prerequisite-patch-id: ba8a0acaf4d6a80a4e74ec209b127a7f34c84f69 -- 2.39.1