Skip to content

Re-raising in guard isn’t within the dynamic environment of the original call to raise #13

@usaoc

Description

@usaoc

In R⁶RS Standard Library Section 7.1, guard is specified as follows:

If every ⟨cond clause⟩’s ⟨test⟩ evaluates to #f and there is no else clause, then raise-continuable is re-invoked on the raised object within the dynamic environment of the original call to raise except that the current exception handler is that of the guard expression. [emphasis mine]

This means in the program

#!r6rs
(import (rnrs))

(guard (con [#f #f])
  (dynamic-wind
    (lambda ()
      (display "entered")
      (newline))
    (lambda ()
      (raise (condition
              (make-message-condition "condition"))))
    (lambda ()
      (display "exited")
      (newline))))

re-raising should be within the dynamic-wind. However, Racket outputs

entered
exited
condition
  context...:
   /path/to/r6rs-lib/r6rs/private/conds.rkt:53:0: condition
   /path/to/test.ss:9:4
   body of "/path/to/test.ss"

which indicates that the dynamic-wind was only exited once. In comparison, Chez Scheme outputs

entered
exited
entered
Exception: condition
exited

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions