Redefining condition can lead to multiple evaluation of initfunctions
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
What I do (this is actually the test case from the attached patch):
(defvar bar-counter 0)
(defvar baz-counter 0)
(define-condition condition-
((bar :initarg :bar
:reader condition-
(baz :initarg :baz
:reader condition-
:initform (incf baz-counter)))
(:default-
(define-condition condition-
((bar :initarg :bar
:reader condition-
(baz :initarg :baz
:reader condition-
:initform (incf baz-counter)))
(:default-
(macrolet ((test (case &body body)
`(progn
(setf bar-counter 0
baz-counter 0)
(let ((instance (progn ,@body)))
(assert
(= 1 (condition-
instance))
nil
,(format nil "Assertion failed for default initarg initfunction for ~A"
case))
(assert
(= 1 (condition-
instance))
nil
,(format nil "Assertion failed for slot initfunction for ~A"
case)))
(assert (= 1 bar-counter))
(assert (= 1 baz-counter)))))
;; Go through EVAL to avoid optimizations.
(test :eval+make-
(eval '(make-condition
'condition
(test :eval+make-instance
(eval '(make-instance
'condition
;; Allow optimizations.
(test :compile+
(make-condition
'condition
(test :compile+
(make-instance
'condition
What happens:
The assertions fail.
What I expected to happen:
All assertions pass.
SBCL version: ~ 1.1.6
Changed in sbcl: | |
status: | New → Fix Committed |
Changed in sbcl: | |
status: | Fix Committed → Fix Released |
The attached series of patches fixes multiple issues. The others are: /bugs.launchpad .net/sbcl/ +bug/1164970 /bugs.launchpad .net/sbcl/ +bug/539517 /bugs.launchpad .net/sbcl/ +bug/1049404
https:/
https:/
https:/