fix `variable-reference->module-source' for submodules
Unlike the `variable-reference->resolved-module-path', the module source one doesn't include a submodule path.
This commit is contained in:
parent
a7ea79040d
commit
506b70f71f
|
@ -414,6 +414,8 @@ result is @racket[#f].}
|
||||||
If @racket[varref] refers to a @tech{module-level variable}, the
|
If @racket[varref] refers to a @tech{module-level variable}, the
|
||||||
result is a path or symbol naming the module's source (which is
|
result is a path or symbol naming the module's source (which is
|
||||||
typically, but not always, the same as in the resolved module path).
|
typically, but not always, the same as in the resolved module path).
|
||||||
|
If the module is a submodule, the result corresponds to the enclosing
|
||||||
|
top-level module's source.
|
||||||
|
|
||||||
If @racket[varref] refers to a @tech{top-level variable}, then the
|
If @racket[varref] refers to a @tech{top-level variable}, then the
|
||||||
result is @racket[#f].}
|
result is @racket[#f].}
|
||||||
|
|
|
@ -496,6 +496,22 @@
|
||||||
|
|
||||||
(test 3 dynamic-require '(submod 'module+-example-2 a b) 'x)
|
(test 3 dynamic-require '(submod 'module+-example-2 a b) 'x)
|
||||||
|
|
||||||
|
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; Check module-source for submodule:
|
||||||
|
|
||||||
|
(let ()
|
||||||
|
(define (go set-name get-name)
|
||||||
|
(parameterize ([current-namespace (make-base-namespace)])
|
||||||
|
(parameterize ([current-module-declare-source set-name])
|
||||||
|
(eval '(module m racket/base
|
||||||
|
(module+ sub
|
||||||
|
(provide v)
|
||||||
|
(define v (variable-reference->module-source
|
||||||
|
(#%variable-reference))))))
|
||||||
|
(test get-name dynamic-require '(submod 'm sub) 'v))))
|
||||||
|
(go #f 'm)
|
||||||
|
(go 'other 'other))
|
||||||
|
|
||||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Check that various shaodwings are allowed:
|
;; Check that various shaodwings are allowed:
|
||||||
|
|
||||||
|
|
|
@ -6064,8 +6064,16 @@ static Scheme_Object *do_module_execute(Scheme_Object *data, Scheme_Env *genv,
|
||||||
if (!SCHEME_FALSEP(src)) {
|
if (!SCHEME_FALSEP(src)) {
|
||||||
src = scheme_intern_resolved_module_path(src);
|
src = scheme_intern_resolved_module_path(src);
|
||||||
m->modsrc = src;
|
m->modsrc = src;
|
||||||
} else
|
} else {
|
||||||
m->modsrc = m->modname;
|
src = m->modname;
|
||||||
|
if (m->submodule_path && !SCHEME_NULLP(m->submodule_path)) {
|
||||||
|
src = scheme_resolved_module_path_value(src);
|
||||||
|
if (SCHEME_PAIRP(src))
|
||||||
|
src = SCHEME_CAR(src);
|
||||||
|
src = scheme_intern_resolved_module_path(src);
|
||||||
|
}
|
||||||
|
m->modsrc = src;
|
||||||
|
}
|
||||||
|
|
||||||
if (genv)
|
if (genv)
|
||||||
env = genv;
|
env = genv;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user