expander: correct some namespace-mismatch error formats

Related to #1352
This commit is contained in:
Matthew Flatt 2021-04-28 07:11:00 -06:00
parent 8962b027fe
commit f4ccd0fdc6
4 changed files with 58 additions and 37 deletions

View File

@ -14370,7 +14370,15 @@ static const char *startup_source =
"(if or-part_1" "(if or-part_1"
" or-part_1" " or-part_1"
"(if complain-on-failure?_0" "(if complain-on-failure?_0"
" (error \"no module instance found:\" name_0 0-phase_0)" "(error"
" 'require"
"(string-append"
" \"namespace mismatch;\\n\""
" \" reference to a module that is not instantiated\\n\""
" \" module: ~a\\n\""
" \" phase: ~a\")"
" name_0"
" 0-phase_0)"
" #f)))))))" " #f)))))))"
"(if(if mi_0 check-available-at-phase-level_0 #f)" "(if(if mi_0 check-available-at-phase-level_0 #f)"
"(check-availablilty mi_0 check-available-at-phase-level_0 unavailable-callback_0)" "(check-availablilty mi_0 check-available-at-phase-level_0 unavailable-callback_0)"
@ -15460,17 +15468,18 @@ static const char *startup_source =
"(if mi_0" "(if mi_0"
"(void)" "(void)"
"(let-values()" "(let-values()"
"(error" "(raise-syntax-error$1"
" 'expand" " #f"
"(format"
"(string-append" "(string-append"
" \"namespace mismatch; cannot locate module instance\\n\"" " \"namespace mismatch;\\n\""
" \" module: ~s\\n\"" " \" cannot locate module instance\\n\""
" \" use phase: ~a\\n\"" " \" module: ~a\\n\""
" \" definition phase: ~a\\n\"" " \" use phase: ~a\\n\""
" \" for identifier: ~s\")" " \" definition phase: ~a\")"
"(module-binding-module b_0)" "(1/module-path-index-resolve(module-binding-module b_0))"
" phase_0" " phase_0"
"(module-binding-phase b_0)" "(module-binding-phase b_0))"
" id_0)))" " id_0)))"
" mi_0))))))" " mi_0))))))"
"(define-values" "(define-values"

View File

@ -17294,7 +17294,12 @@
or-part_2 or-part_2
(if complain-on-failure?55_0 (if complain-on-failure?55_0
(error (error
"no module instance found:" 'require
(string-append
"namespace mismatch;\n"
" reference to a module that is not instantiated\n"
" module: ~a\n"
" phase: ~a")
name62_0 name62_0
0-phase63_0) 0-phase63_0)
#f)))))))) #f))))))))
@ -18366,21 +18371,20 @@
(void)) (void))
(if mi_0 (if mi_0
(void) (void)
(let ((app_0 (raise-syntax-error$1
(string-append #f
"namespace mismatch; cannot locate module instance\n" (let ((app_0
" module: ~s\n" (string-append
" use phase: ~a\n" "namespace mismatch;\n"
" definition phase: ~a\n" " cannot locate module instance\n"
" for identifier: ~s"))) " module: ~a\n"
(let ((app_1 (module-binding-module b_0))) " use phase: ~a\n"
(error " definition phase: ~a")))
'expand (let ((app_1
app_0 (1/module-path-index-resolve
app_1 (module-binding-module b_0))))
phase_0 (format app_0 app_1 phase_0 (module-binding-phase b_0))))
(module-binding-phase b_0) id_0))
id_0))))
mi_0))))) mi_0)))))
(define check-access (define check-access
(lambda (b_0 mi_0 id_0 in-s_0 what_0) (lambda (b_0 mi_0 id_0 in-s_0 what_0)

View File

@ -30,14 +30,15 @@
(phase+ at-phase (module-binding-phase b))) (phase+ at-phase (module-binding-phase b)))
id)) id))
(unless mi (unless mi
(error 'expand (raise-syntax-error
(string-append "namespace mismatch; cannot locate module instance\n" #f
" module: ~s\n" (format (string-append "namespace mismatch;\n"
" use phase: ~a\n" " cannot locate module instance\n"
" definition phase: ~a\n" " module: ~a\n"
" for identifier: ~s") " use phase: ~a\n"
(module-binding-module b) " definition phase: ~a")
phase (module-path-index-resolve (module-binding-module b))
(module-binding-phase b) phase
id)) (module-binding-phase b))
id))
mi) mi)

View File

@ -270,7 +270,14 @@
(let ([c-ns (or (namespace-root-namespace ns) ns)]) (let ([c-ns (or (namespace-root-namespace ns) ns)])
(hash-ref (namespace-module-instances c-ns) name #f)) (hash-ref (namespace-module-instances c-ns) name #f))
(and complain-on-failure? (and complain-on-failure?
(error "no module instance found:" name 0-phase)))) (error 'require
(string-append
"namespace mismatch;\n"
" reference to a module that is not instantiated\n"
" module: ~a\n"
" phase: ~a")
name
0-phase))))
(if (and mi check-available-at-phase-level) (if (and mi check-available-at-phase-level)
(check-availablilty mi check-available-at-phase-level unavailable-callback) (check-availablilty mi check-available-at-phase-level unavailable-callback)
mi)) mi))