repair a problem with module->namespace
Fix a problem with compile-time bindings added to a namespace created by `module->namespace` for a module that does not have a source file. Possibly, there's a different fault that should be fixed that caused a binding to use the module's instantiation-time module path index instead of its compile-time module path index (which is what happens when a file is involved). This repair fixes the problem in a general way, though, and leaves further improvement to the reimplementation of the expander in Racket (which already does not suffer from the bug). Thanks to Alexis for providing the example.
This commit is contained in:
parent
59fc3758f0
commit
664bec2040
|
@ -2048,6 +2048,25 @@ case of module-leve bindings; it doesn't cover local bindings.
|
|||
|
||||
(test 1 dynamic-require '(submod 'uses-own-namespace-for-eval-from-submodule main) 'v)
|
||||
|
||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Make sure a module that isn't in a file
|
||||
;; correctly introduces and references compile-time
|
||||
;; top-level definitions
|
||||
|
||||
(parameterize ([current-namespace (make-base-namespace)])
|
||||
(eval '(module m racket
|
||||
|
||||
(require syntax/parse/define)
|
||||
|
||||
(define-simple-macro (f m:id)
|
||||
(begin
|
||||
(define-for-syntax x "prop value")
|
||||
(define-syntax (m stx) x #'(void))))))
|
||||
(eval '(dynamic-require ''m #f))
|
||||
(let ([ns (module->namespace ''m)])
|
||||
(eval '(f m) ns)
|
||||
(eval '(m) ns)))
|
||||
|
||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(report-errs)
|
||||
|
|
|
@ -1869,10 +1869,12 @@ static Scheme_Object *select_binding_name(Scheme_Object *sym, Scheme_Env *env,
|
|||
static int binding_matches_env(Scheme_Object *binding, Scheme_Env *env, Scheme_Object *phase)
|
||||
{
|
||||
return (SCHEME_VECTORP(binding)
|
||||
&& SAME_OBJ(SCHEME_VEC_ELS(binding)[0],
|
||||
(env->module
|
||||
? env->module->self_modidx
|
||||
: scheme_false))
|
||||
&& (SAME_OBJ(SCHEME_VEC_ELS(binding)[0],
|
||||
(env->module
|
||||
? env->module->self_modidx
|
||||
: scheme_false))
|
||||
|| SAME_OBJ(SCHEME_VEC_ELS(binding)[0],
|
||||
env->link_midx))
|
||||
&& SAME_OBJ(SCHEME_VEC_ELS(binding)[2], phase));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user