use the module name resolver to check if the language is valid

svn: r10542
This commit is contained in:
Eli Barzilay 2008-07-01 19:04:00 +00:00
parent bf2fe2f64c
commit b097856a72

View File

@ -469,12 +469,22 @@
[lang-only (with-handlers ([void (λ (e) #f)]) [lang-only (with-handlers ([void (λ (e) #f)])
(expand lang-only))]) (expand lang-only))])
(if lang-only (if lang-only
(let ([rep (drscheme:rep:current-rep)]) (begin
((error-display-handler) (exn-message exn) exn) ((error-display-handler) (exn-message exn) exn)
;; probably best to not say anything here ;; 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) 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 ;; Expand the module expression, so we can catch an syntax errors and
;; provide a repl with the base language in that case. ;; provide a repl with the base language in that case.
(define expr* (with-handlers ([exn? only-language]) (expand expr))) (define expr* (with-handlers ([exn? only-language]) (expand expr)))