summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ice-9/boot-9.scm20
1 files changed, 14 insertions, 6 deletions
diff --git a/ice-9/boot-9.scm b/ice-9/boot-9.scm
index 7756b4ccd..e5bdd6738 100644
--- a/ice-9/boot-9.scm
+++ b/ice-9/boot-9.scm
@@ -1529,12 +1529,20 @@
;; the standard eval closure defines a binding
(module-modified m)
b)))
- (and (module-binder m)
- ((module-binder m) m v #t))
- (begin
- (let ((answer (make-undefined-variable)))
- (module-add! m v answer)
- answer))))
+
+ ;; No local variable yet, so we need to create a new one. That
+ ;; new variable is initialized with the old imported value of V,
+ ;; if there is one.
+ (let ((imported-var (module-variable m v))
+ (local-var (or (and (module-binder m)
+ ((module-binder m) m v #t))
+ (begin
+ (let ((answer (make-undefined-variable)))
+ (module-add! m v answer)
+ answer)))))
+ (if (and imported-var (not (variable-bound? local-var)))
+ (variable-set! local-var (variable-ref imported-var)))
+ local-var)))
;; module-ensure-local-variable! module symbol
;;