fix `namespace-attach-module{-declaration}' problem

Closes PR 12048
This commit is contained in:
Matthew Flatt 2011-08-02 17:04:22 -06:00
parent b972a0940d
commit 3b8d00029e
2 changed files with 24 additions and 0 deletions

View File

@ -174,6 +174,17 @@
(test 'va->ms dynamic-require ''va->ms 'modsrc)
;; ----------------------------------------
;; Check that `namespace-attach-module-declaration' doesn't
;; trigger the module-name resolver in the wrong namespace:
(let ()
(define ns0 (make-base-namespace))
(eval '(module sample racket (#%module-begin)) ns0)
(define ns1 (make-empty-namespace))
(parameterize ([current-namespace ns1])
(namespace-attach-module-declaration ns0 ''sample ns1)))
;; ----------------------------------------
(report-errs)

View File

@ -1677,12 +1677,25 @@ static Scheme_Object *do_namespace_attach_module(const char *who, int argc, Sche
name);
else {
/* instantiate for-label: */
Scheme_Cont_Frame_Data cframe;
Scheme_Config *config;
/* make sure `from_env' is the current namespace, because
start_module() may need to resolve module paths: */
config = scheme_extend_config(scheme_current_config(),
MZCONFIG_ENV,
(Scheme_Object *)from_env);
scheme_push_continuation_frame(&cframe);
scheme_set_cont_mark(scheme_parameterization_key, (Scheme_Object *)config);
start_module(m2,
from_env->label_env, 0,
main_modidx,
0, 0, from_env->phase,
scheme_null);
scheme_pop_continuation_frame(&cframe);
/* try again: */
menv = (Scheme_Env *)scheme_hash_get(MODCHAIN_TABLE(from_env->label_env->modchain), name);
}