[ansi-test-devel] Local function binding shadows global macro

Pascal J. Bourguignon pjb at informatimago.com
Thu Aug 25 23:37:10 UTC 2011


Erik Huelsmann <ehuels at gmail.com> writes:

> This week, I fixed an error in ABCL for which there seems to be no conformance test: a local function binding shadows global macros and compiler macros.
>
> I'm not really sure how to set up a good test for it within the ansi tests framework, but this is the code which caused the issue in ABCL:
>
> (defmacro var (name &optional value docs)
>    `(defparameter ,name ,@(when value (list value))))
>
> (defun make-var (the-name))
>
> (defun foo (var-ref)
>   (flet ((var (x) (second x)))
>      `(make-var ,(var x))))
>
> Any ideas about translating this into a good test to be committed?
>
> Maybe we could come up with a similar test for compiler macros as well?

You don't need anything fancy.

(defmacro var ()
  '1)

(assert (= 2 (flet ((var () 2))
               (var))))

(assert (= 3 (macrolet ((var () '3))
               (var))))

(assert (= 4 (macrolet ((var () '3))
               (flet ((var () 4))
                 (var)))))

(assert (= 3 (flet ((var () 2))
               (macrolet ((var () '3))
                 (var)))))

Also, with a toplevel DEFUN and using LABELS instead of FLET.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.





More information about the ansi-test-devel mailing list