From f7cd2b8775d1b3061998ce9c2d726769cc549f0f Mon Sep 17 00:00:00 2001 From: Marius Gerbershagen Date: Wed, 20 Mar 2019 22:40:21 +0100 Subject: [PATCH] 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. --- src/lsp/defstruct.lsp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lsp/defstruct.lsp b/src/lsp/defstruct.lsp index 2b67c6851..abbb55dad 100644 --- a/src/lsp/defstruct.lsp +++ b/src/lsp/defstruct.lsp @@ -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