Steel Bank Common Lisp

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

Reported by Douglas Katzman on 2012-09-11
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Undecided
Unassigned

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)))
CRASH
* (describe(make-condition 'crash))
#<CRASH {1076CB6583}>
  [condition]
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)

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

* (lisp-implementation-version)
"1.0.58.28-60bb508-dirty"

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