[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Print backtraces for syntax errors too.

From: Maxime Devos
Subject: [PATCH] Print backtraces for syntax errors too.
Date: Wed, 8 Feb 2023 16:59:05 +0100

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]