fix expand + compile + write + read + module->namespace

... + prefix-in + relative-path module. All of those ingredients
(or some similar alternatives) are necessary to trigger a slow
way of saving module context for interaction evaluation where
a module-path index shift was getting lost.
This commit is contained in:
Matthew Flatt 2016-10-26 17:09:30 -06:00
parent f159295e55
commit cb6af9664c
2 changed files with 33 additions and 0 deletions

View File

@ -1827,6 +1827,33 @@ case of module-leve bindings; it doesn't cover local bindings.
(dynamic-require ''rexports-values-from-kernel 'f)
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Check that shifts associated with re-expansion are
;; properly tracked for `module->namespace`
(parameterize ([current-load-relative-directory
(let-values ([(b n dir?)
(split-path
(collection-file-path "promise.rkt" "racket"))])
b)])
(let* ([e (expand (namespace-syntax-introduce
(datum->syntax #f '(module m racket/base
;; A prefixed import forces saving of the
;; context as a syntax object in marshaled
;; form:
(require (prefix-in p: "promise.rkt"))))))]
[c (compile e)]
[o (open-output-bytes)]
[_ (write c o)]
[r (parameterize ([read-accept-compiled #t])
(read (open-input-bytes (get-output-bytes o))))])
(parameterize ([current-namespace (make-base-namespace)])
(eval r)
(dynamic-require ''m #f)
(parameterize ([current-namespace (module->namespace ''m)])
(and (memq 'p:force (namespace-mapped-symbols))
#t)))))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(report-errs)

View File

@ -7601,6 +7601,12 @@ static Scheme_Object *do_module(Scheme_Object *form, Scheme_Comp_Env *env,
/* phase shift to replace self_modidx of previous expansion: */
fm = scheme_stx_shift(fm, NULL, this_empty_self_modidx, self_modidx, NULL,
m->insp, m->insp);
if (m->ii_src) {
/* shift the initial import to record the chain for rn_stx */
ii = scheme_stx_shift(m->ii_src, NULL, this_empty_self_modidx, self_modidx, NULL,
m->insp, m->insp);
m->ii_src = ii;
}
fm = scheme_stx_add_module_frame_context(fm, rn_set);