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

Bug in Victoria Day PCL



There is a rare bug in Victoria Day PCL which appears under the
following circumstances:

  (defclass c2 (c1) ((my-slot :allocation :class)))
				;; Note: c1 is not yet defined

  (defclass c3 (c2) ())
				;; Should be ok, but...

  Not an array: nil


This bug only appears when
     (1) "c1" isn't defined (i.e. it's forward-referenced);
     (2) there is at least one slot in "c2" allocated in the class;
     (3) a specialization to "c2" is defined before "c1" is
         defined (i.e. "c3" is defined when "c1" is still
         forward-referenced); and
     (4) "c3" doesn't redefine inherited class-slots (i.e. "my-slot"
         is not redefined in "c3"). 

The problem is that the "wrapper-slot" of "c2" isn't asserted when
"c3" is defined (because "c1" is forward-referenced). The wrapper of
"c2" is needed in this particular situation to construct the wrapper
of "c3" (i.e. to get the inherited class slots).

A simple fix would be to change the following expression in the function
update-slots--class in the file std-class.lisp:

;--------
      (setf (wrapper-class-slots nwrapper)
	    (gathering1 (collecting)
	      (dolist (slotd inherited-class-slots)
		(gather1 (assoc (slotd-name slotd)
				(wrapper-class-slots
				  (class-wrapper (slotd-allocation slotd))))))
	      (dolist (slotd class-slots)
		(gather1 (cons (slotd-name slotd)
			       (funcall (slotd-initfunction slotd)))))))
;--------

into this:

;++++++++
      (setf (wrapper-class-slots nwrapper)
	    (gathering1 (collecting)
	      (dolist (slotd inherited-class-slots)
		(gather1 (and (arrayp (class-wrapper (slotd-allocation slotd)))
			      (assoc (slotd-name slotd)
				(wrapper-class-slots
				  (class-wrapper (slotd-allocation slotd)))))))
	      (dolist (slotd class-slots)
		(gather1 (cons (slotd-name slotd)
			       (funcall (slotd-initfunction slotd)))))))
;++++++++

The above works since the wrapper gets updated when the
forward-referenced super-class is declared. There is probably a
"better" fix for this bug. However, this seems to work reasonably
well.


Henrik Eriksson
-------