[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug in walking setq of slot

Our most recent version of PCL (which I guess is the Valentine's day
version--it was snarfed on the 15th) has a rather bad bug that causes
setq of a slot-variable to fail to compile properly.  Ie:

(defclass thing ()
	 (x y))

(defmethod gazork ((a thing) b)
  (with-slots* (x) a
    (setq x b)))

The gazork method will get compile errors.

The following patch seems to fix things in the Symbolics version.  

(defun with-slots-internal (specs form context translate-fn &aux entry)
  (cond ((not (eq context :eval)) form)
	((symbolp form)
	 (if (setq entry (assoc form specs))
	     (funcall translate-fn (cadr entry))
	((not (listp form)) form)
	((member (car form) '(setq setf))
	 ;; Have to be careful.  We must only convert the form to a SETF
	 ;; form when we convert one of the 'logical' variables to a form
	 ;; Otherwise we will get looping in implementations where setf
	 ;; is a macro which expands into setq.
	 (let ((kind (car form)))
	   (labels ((scan-setf (tail)
		      (if (null tail)
			    (if (setq entry (assoc (car tail) specs))
				(progn (setq kind 'setf)
				       (funcall translate-fn (cadr entry)))
				(car tail))
			    (cadr tail)
			    (scan-setf (cddr tail))))))
	     (let ((set-args (scan-setf (cdr form))))
	       (walker::recons form kind set-args)))))
	(t form)))