COMPUTE-SLOTS incorrect for structure-class and condition-class
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
For structures, a duplicate effective-
* (defstruct animal name size)
ANIMAL
* (defstruct (dog (:include animal (name "Spot") (size))) tail-wag-
DOG
* (sb-pcl:class-slots (find-class 'dog))
(#<SB-PCL:
#<SB-PCL:
#<SB-PCL:
#<SB-PCL:
#<SB-PCL:
This affects ~70 structure classes in a pristine image, plus stuff we define using the same approach of overriding a default. It's surprising this escaped attention thus far considering that DESCRIBE is pretty obviously screwy as a consequence.
Here is a probably-working patch for the STRUCTURE-CLASS method:
diff --git a/src/pcl/
index 9c077f9..ffe7b65 100644
--- a/src/pcl/
+++ b/src/pcl/
@@ -1125,14 +1125,22 @@
(std-
(defmethod compute-slots ((class structure-class))
- (mapcan (lambda (superclass)
- (mapcar (lambda (dslotd)
- (compute-
- class
- (slot-definitio
- (list dslotd)))
- (class-direct-slots superclass)))
- (reverse (slot-value class '%class-
+ (let (eslotds)
+ (mapc (lambda (superclass)
+ (mapc (lambda (dslotd)
+ (let* ((slot-name (slot-definitio
+ (eslotd
+ (compute-
+ class slot-name (list dslotd)))
+ (found (member slot-name eslotds
+ :key #'slot-
+ :test #'string=)))
+ (if found
+ (rplaca found eslotd)
+ (push eslotd eslotds))))
+ (class-direct-slots superclass)))
+ (reverse (slot-value class '%class-
+ (nreverse eslotds)))
There is something unsettling about the 'string=' and I think it's wrong, but at the time I fixed this I was also looking into what I think is another bug. Namely, if you include a structure and specify a list of slots whose descriptions to alter, it doesn't "work" to refer to the slot using a symbol in the wrong package. So are they compared by print-name or aren't they? Now that I think about it more, this could be a consequence of a bug which subsumes it, namely: if you specify a slot that doesn't exist at all in the ancestor, no complaint is generated. It looks like it's just ignored.
Back to the original problem - For condition-class, the confusion is greater since multiple inheritance yields possibly N instances of a same-named direct-
./src/runtime/sbcl --version
SBCL 1.0.58.
Changed in sbcl: | |
status: | Fix Committed → Fix Released |
fixed in 91f7d85a9528eb8 1d8da70a2900d86 8ee29b36b7 b9180b3fa9c7fcb 3206174790
and then again in 1891fa69bddd2ca