diff tests/automated/lisp-tests.el @ 5658:289cf21be887

Don't augment ENVIRONMENT when that's not indicated, #'macroexpand. This reflects better understanding on my part of the &environment macro keyword, and I've expanded the Lisp manual and docstrings to reflect that. lisp/ChangeLog addition: 2012-05-06 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (block): Comment on why we can't use &environment here. * cl-macs.el (defmacro*): Document &environment in more detail. * cl-macs.el (macrolet): Use &environment, instead of referencing byte-compile-macro-environment directly. * cl-macs.el (symbol-macrolet): Ditto. * cl-macs.el (lexical-let): Ditto. * cl-macs.el (labels): Ditto. man/ChangeLog addition: 2012-05-06 Aidan Kehoe <kehoea@parhasard.net> * lispref/macros.texi (Expansion): Cross-reference to documentation of #'cl-prettyexpand, #'defmacro* when talking about #'macroexpand. tests/ChangeLog addition: 2012-05-06 Aidan Kehoe <kehoea@parhasard.net> * automated/lisp-tests.el: Use &environment appropriately in #'macrolet, instead of relying on #'macroexpand to guess what we mean.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 06 May 2012 15:29:59 +0100
parents 5bda701e9e7c
children 37479d841681
line wrap: on
line diff
--- a/tests/automated/lisp-tests.el	Sun May 06 05:22:19 2012 +0100
+++ b/tests/automated/lisp-tests.el	Sun May 06 15:29:59 2012 +0100
@@ -2957,10 +2957,10 @@
         (append form (list 1 [hi there] 40 "this is a string" pi)))
        (with-second-arguments (&optional form)
          (append form (list pi e ''hello ''there [40 50 60])))
-       (with-both-arguments (&optional form)
+       (with-both-arguments (&optional form &environment env)
          (append form
-                 (macroexpand '(with-first-arguments))
-                 (macroexpand '(with-second-arguments)))))
+                 (macroexpand '(with-first-arguments) env)
+                 (macroexpand '(with-second-arguments) env))))
 
     (with-temp-buffer
       (Assert
@@ -2986,4 +2986,20 @@
       (Assert (not (funcall (intern "eq") #'bookend #'refer-to-bookend))
 	      "checking two mutually recursive functions compiled OK"))))
 
+;; Test macroexpand's handling of the ENVIRONMENT argument. We augmented it
+;; quietly for about four months, and this was incorrect.
+
+(Check-Error
+ void-variable
+ (macrolet
+     ((with-first-arguments (&optional form)
+        (append form (list 1 [hi there] 40 "this is a string" pi)))
+      (with-second-arguments (&optional form)
+        (append form (list pi e ''hello ''there [40 50 60])))
+      (with-both-arguments (&optional form)
+        (append form
+                (macroexpand '(with-first-arguments))
+                (macroexpand '(with-second-arguments)))))
+   (with-both-arguments (list))))
+
 ;;; end of lisp-tests.el