racket/enter: fix exception handling & propagation for `enter!'
Merge to v5.3.4
(cherry picked from commit 9a52894b8b
)
This commit is contained in:
parent
fd4f374195
commit
045cf69ba4
|
@ -35,15 +35,28 @@
|
|||
(define (do-enter! mod flags)
|
||||
(let ([flags (check-flags flags)])
|
||||
(if mod
|
||||
(let* ([none "none"]
|
||||
[exn (with-handlers ([void (lambda (exn)
|
||||
(log-enter!-error "~a" (exn-message exn)))])
|
||||
(enter-require mod flags)
|
||||
none)]
|
||||
[ns (module->namespace mod)])
|
||||
(current-namespace ns)
|
||||
(unless (memq '#:dont-re-require-enter flags)
|
||||
(namespace-require 'racket/enter))
|
||||
(let* ([none (gensym)]
|
||||
[exn (with-handlers ([void (lambda (exn) exn)])
|
||||
(if (module-path? mod)
|
||||
(enter-require mod flags)
|
||||
(raise-argument-error 'enter! "module-path?" mod))
|
||||
none)])
|
||||
;; Try to switch to the module namespace,
|
||||
;; even if there was an exception, because the
|
||||
;; idea is to allow debugging from inside the
|
||||
;; module. If any excepiton happens in trying to
|
||||
;; switch to the declared module, log that as
|
||||
;; an internal exception.
|
||||
(with-handlers ([void (lambda (exn)
|
||||
(if (exn? exn)
|
||||
(log-enter!-error (exn-message exn))
|
||||
(log-enter!-error "~s" exn)))])
|
||||
(when (and (module-path? mod)
|
||||
(module-declared? mod #f))
|
||||
(let ([ns (module->namespace mod)])
|
||||
(current-namespace ns)
|
||||
(unless (memq '#:dont-re-require-enter flags)
|
||||
(namespace-require 'racket/enter)))))
|
||||
(unless (eq? none exn) (raise exn)))
|
||||
(current-namespace orig-namespace))))
|
||||
|
||||
|
|
|
@ -1,4 +1,13 @@
|
|||
#lang racket
|
||||
(require racket/enter)
|
||||
|
||||
;; Make sure that when a module has a syntax error, we still
|
||||
;; switch into the module's namespace:
|
||||
(parameterize ([current-namespace (make-base-namespace)])
|
||||
(eval '(module f racket/base (define f 'yes) (raise-user-error 'oops "broken")))
|
||||
(with-handlers ([exn:fail:user? void]) (enter! 'f))
|
||||
(unless (eq? 'yes (eval 'f))
|
||||
(error "not in f?")))
|
||||
|
||||
;; Make sure that `enter!' can work on lots of modules:
|
||||
(enter! slideshow/pict)
|
||||
|
|
Loading…
Reference in New Issue
Block a user