Fix 'local-eval' when the specified environment is a module
authorMark H Weaver <mhw@netris.org>
Mon, 30 Jan 2012 08:02:32 +0000 (03:02 -0500)
committerMark H Weaver <mhw@netris.org>
Mon, 30 Jan 2012 08:02:32 +0000 (03:02 -0500)
* module/ice-9/local-eval.scm (local-wrap): Fix the (module? e) case, to
  reference the expression 'x' instead of the non-existent variable
  'exp', as was previously done.  Also use quasisyntax instead of
  quasiquote, so that the introduced 'lambda' is an identifier instead
  of a bare symbol, so that this will work in modules that have rebound
  'lambda' to something else.

* test-suite/tests/eval.test (local-eval): Make sure to test both
  'local-eval' and 'local-compile' when the specified environment is a
  module.

module/ice-9/local-eval.scm
test-suite/tests/eval.test

index f01a9c6..28f30b9 100644 (file)
                         (scope (caddr l)))
                     (within-nested-ellipses (datum->syntax scope name) lvl)))
                 (lexenv-patterns e))))
-   ((module? e) `(lambda () #f ,exp))
+   ((module? e) #`(lambda () #f #,x))
    (else (error "invalid lexical environment" e))))
 
 (define (local-eval x e)
index f532059..b0bfd4c 100644 (file)
 
   (pass-if "local-eval"
 
-    (let* ((env1 (let ((x 1) (y 2) (z 3))
-                   (define-syntax-rule (foo x) (quote x))
-                   (the-environment)))
+    (let* ((env1 (local-eval '(let ((x 1) (y 2) (z 3))
+                                (define-syntax-rule (foo x) (quote x))
+                                (the-environment))
+                             (current-module)))
            (env2 (local-eval '(let ((x 111) (a 'a))
                                 (define-syntax-rule (bar x) (quote x))
                                 (the-environment))
 
   (pass-if "local-compile"
 
-    (let* ((env1 (let ((x 1) (y 2) (z 3))
-                   (define-syntax-rule (foo x) (quote x))
-                   (the-environment)))
+    (let* ((env1 (local-compile '(let ((x 1) (y 2) (z 3))
+                                   (define-syntax-rule (foo x) (quote x))
+                                   (the-environment))
+                                (current-module)))
            (env2 (local-compile '(let ((x 111) (a 'a))
                                    (define-syntax-rule (bar x) (quote x))
                                    (the-environment))
                      (the-environment))))
               module-a)
         (module-use! module-b (resolve-interface '(guile)))
-        (let ((env (eval `(let ((x 111) (y 222))
-                            ((@@ ,module-a-name test)))
-                         module-b)))
+        (let ((env (local-eval `(let ((x 111) (y 222))
+                                  ((@@ ,module-a-name test)))
+                               module-b)))
           (equal? (local-eval '(list x y z) env)
                   '(1 2 3))))))