apparently this has been fixed between 3.0.9 and HEAD. i've wasted my time 
chasing a ghost...

can we please have a new release? :)

as a sidenote, i also had some broken expectations in my test.scm.

it's a tangential, but namely, when #:unwind #t then the handler in a w-e-h 
returns from the w-e-h block, but with #:unwind #f it tries to return to the 
RAISE that raised the condition. i.e. a lousy little keyword arg (usually a 
page down) fundamentally changes the behavior of w-e-h. yet another surprise 
that violated my expectations regarding APIs.

anyway, i've attached a patch that clarifies what's happening for anyone who 
stumbles upon this; i.e. be clearer that (?) a backtrace is printed due to 
reaching a continuation barrier.

this makes it grep'able, and if the user also prints a backtrace, then it makes 
it clear that it's something printed by guile.

if someone wants to investigate further, then i'm also attaching a new version 
of my test.scm that behaves in an unexpected way on 3.0.9, but not on HEAD 
(more specifically on guile-next in guix, which is a rather recent commit).

HTH,

-- 
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
All men dream, but not equally. Those who dream by night in the dusty recesses 
of their minds wake in the day to find that it was vanity. But the dreamers of 
the day are dangerous men, for they may act their dream with open eyes to make 
it possible.
From d45817097181d4a5812405474ac7b24af3531f7a Mon Sep 17 00:00:00 2001
From: Attila Lendvai <att...@lendvai.name>
Date: Mon, 17 Jun 2024 19:46:45 +0200
Subject: [PATCH] More specific error message for exceptions at continuation
 barriers

---
 libguile/continuations.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libguile/continuations.c b/libguile/continuations.c
index b8b6e1dca..49f8266dd 100644
--- a/libguile/continuations.c
+++ b/libguile/continuations.c
@@ -405,7 +405,7 @@ print_exception_and_backtrace (SCM port, SCM tag, SCM args)
 
   if (should_print_backtrace (tag, stack))
     {
-      scm_puts ("Backtrace:\n", port);
+      scm_puts ("An exception has reached a continuation barrier:\n", port);
       scm_display_backtrace_with_highlights (stack, port,
                                              SCM_BOOL_F, SCM_BOOL_F,
                                              SCM_EOL);
-- 
2.45.1

#!/usr/bin/env -S guile --no-auto-compile -e main -s
!#

(use-modules (ice-9 control))

(define* (test #:key (unwind? #f))
  (let/ec return
    (with-exception-handler
        (let ((nested #f))
          (lambda (c-level-1)
            (if nested
                (begin
                  (format #t "level 1 handler got called recursively~%")
                  'level-1-handler-nested)
                (begin
                  (set! nested #t)
                  (with-exception-handler
                      (lambda (c-level-2)
                        (begin
                          (format #t "level 2 handler got error ~A~%" c-level-2)
                          (format #t "level 2 handler is returning~%")
                          (return 'level-2-handler)))
                    (lambda ()
                      (format #t "level 1 handler~%")
                      (error "let's signal a nested error...")
                      (format #t "level 1 handler is returning~%")
                      (return 'level-1-handler))
                    #:unwind? unwind?)))))
      (lambda ()
        (error "let's signal an error...")
        'thunk)
      #:unwind? unwind?)))

(define (main cmd)
  (unsetenv "COLUMNS")
  (format #t "~%~%*** calling with unwind~%")
  (format #t "return value is: ~A~%" (test #:unwind? #t))
  (format #t "~%~%*** calling without unwind~%")
  (format #t "return value is: ~A~%" (test #:unwind? #f)))
  • bug#46009: exce... Maxime Devos
    • bug#46009:... Attila Lendvai
      • bug#46... Attila Lendvai
        • bu... Bug reports for GUILE, GNU's Ubiquitous Extension Language
          • ... Attila Lendvai
            • ... Bug reports for GUILE, GNU's Ubiquitous Extension Language
              • ... Attila Lendvai
                • ... Bug reports for GUILE, GNU's Ubiquitous Extension Language

Reply via email to