DEFINE-CONDITION slot option :ALLOCATION :CLASS "almost" works

Bug #1049404 reported by Douglas Katzman on 2012-09-11
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

The macro accidentally omits the :allocation initarg from MAKE-CONDITION-SLOT, so all slots get :instance allocation.

* (define-condition crash () ((count :accessor crash-count :initform 0 :allocation :class)))
* (describe(make-condition 'crash))
#<CRASH {1076CB6583}>
Slots with :INSTANCE allocation:
  COUNT = 0

It's a trivial fix though as the internals are apparently in good working order.

diff --git a/src/code/condition.lisp b/src/code/condition.lisp
index ab6e942..e854e8e 100644
--- a/src/code/condition.lisp
+++ b/src/code/condition.lisp
@@ -533,6 +533,7 @@
             (all-writers (writers))
             (slots `(make-condition-slot
                      :name ',slot-name
+ :allocation ',allocation
                      :initargs ',(initargs)
                      :readers ',(readers)
                      :writers ',(writers)

* (progn (loop repeat 5 do (incf (crash-count (make-condition 'crash)))) (describe(make-condition 'crash)))
#<CRASH {1002E38763}>
Slots with :CLASS allocation:
  COUNT = 5

* (lisp-implementation-version)

Incidentally, the docstring says that WITH-SLOTS and SLOT-VALUE may not be used, but they seem to work.

Jan Moringen (scymtym) wrote :
Changed in sbcl:
status: New → Fix Committed
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers