From b097856a721820f791dabf83c7e4711be0a87222 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Tue, 1 Jul 2008 19:04:00 +0000 Subject: [PATCH] use the module name resolver to check if the language is valid svn: r10542 --- collects/drscheme/private/module-language.ss | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/collects/drscheme/private/module-language.ss b/collects/drscheme/private/module-language.ss index cb6ec59b3b..265f7ae7db 100644 --- a/collects/drscheme/private/module-language.ss +++ b/collects/drscheme/private/module-language.ss @@ -469,12 +469,22 @@ [lang-only (with-handlers ([void (λ (e) #f)]) (expand lang-only))]) (if lang-only - (let ([rep (drscheme:rep:current-rep)]) + (begin ((error-display-handler) (exn-message exn) exn) ;; probably best to not say anything here - ;; (send rep insert-warning "Definitions not in effect") + ;; (send (drscheme:rep:current-rep) insert-warning + ;; "Definitions not in effect") lang-only) - (raise-hopeless-exception exn "invalid language specification")))) + ;; say that it's an invalid language only if it doesn't resolve + ;; properly, because the language can be fine but throw a syntax + ;; error when there are no body expressions (for example, the + ;; syntax/module-reader language) + (raise-hopeless-exception + exn + (with-handlers ([void (lambda (_) + "invalid language specification")]) + ((current-module-name-resolver) 'scheme #f #f) + #f))))) ;; Expand the module expression, so we can catch an syntax errors and ;; provide a repl with the base language in that case. (define expr* (with-handlers ([exn? only-language]) (expand expr)))