Re: bug in macro handling?

JP Massar <[email protected]> Sat, 12 Apr 2003 10:20:28 -0700
Newsgroups gmane.lisp.corman
Message-ID <[email protected]>
>
>
>Does anyone have an idea what's going on?

It's a bug in PUSH.

If you do a straight SETF using a macro it works:

(setq x (make-hash-table))

(defmacro foo (key ht) `(gethash ,key ,ht))
FOO

(setf (foo 4 x) '(a b c))
(A B C)

(gethash 4 x)
(A B C)

(push 'e (foo 4 x))

;;; An error occurred in function #< COMPILED-FUNCTION: #x12832B8 >:
;;; Error: The function NIL is undefined

(macroexpand-1 '(push e (foo 4 x)))
(MULTIPLE-VALUE-BIND (#:G2288) E
   (LET* ((#:G2289 4) (#:G2290 X))
     (MULTIPLE-VALUE-BIND (#:G2291)
         (FOO #:G2289 #:G2290)
       (NIL (CONS #:G2288 #:G2291) #:G2289 #:G2290))))

The program is the NIL in the last line.

A cursory examination of PUSH does not suggest
an immediate fix.

The workaround is to replace the PUSH by an equivalent SETF.

(setf (foo 4 x) (cons 'd (foo 4 x)))
(D A B C)