defstruct: be less strict about struct redefinitions

Only disallow struct redefinition if we are certain about subtype
relationships in slots. Otherwise, we can wrongly disallow struct
redefinitions which don't change slot types.
This commit is contained in:
Marius Gerbershagen 2019-03-20 22:40:21 +01:00
parent 177ad215ea
commit f7cd2b8775

View file

@ -313,14 +313,18 @@
(or (equal old-def new-def)
(destructuring-bind (old-slot-name old-init old-type old-read-only old-offset old-ac)
old-def
(declare (ignore old-init read-only old-ac))
(declare (ignore old-init old-read-only old-ac))
(destructuring-bind (new-slot-name new-init new-type new-read-only new-offset new-ac)
new-def
(declare (ignore new-init new-read-only new-ac))
(and (eql old-slot-name new-slot-name)
(= old-offset new-offset)
(and (subtypep old-type new-type)
(subtypep new-type old-type)))))
(and (multiple-value-bind (subtypep certain)
(subtypep old-type new-type)
(or (not certain) subtypep))
(multiple-value-bind (subtypep certain)
(subtypep new-type old-type)
(or (not certain) subtypep))))))
(return-from %struct-layout-compatible-p nil)))))
(defun define-structure (name conc-name type named slots slot-descriptions