bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#20914: eieio/slot/group


From: Pierre Lorenzon
Subject: bug#20914: eieio/slot/group
Date: Mon, 29 Jun 2015 19:29:52 +0200 (CEST)


OK I got it !

The problem comes from use of `copy-sequence' in
`eieio-copy-parents-into-subclass' function of eieio-core. this
copy is not reccursive as explained in code comment but it
should be ! There's a joined patch that fixes the bug.

Regards

Pierre

--- eieio-core..orig.el 2015-06-28 07:26:49.000000000 +0200
+++ eieio-core.el       2015-06-29 19:20:28.000000000 +0200
@@ -660,9 +660,32 @@
       (let ((pslots (eieio--class-slots pcv))
             (pinit (eieio--class-initarg-tuples pcv)))
         (dotimes (i (length pslots))
-         (let* ((sd (cl--copy-slot-descriptor (aref pslots i)))
+         ;;;  -- Props should be copied as well 
+         ;;; PLN Mon Jun 29 17:25:54 2015
+         ;;
+         ;; Due to the way `cl--copy-slot-descriptor' acts
+         ;; props in the copied object will not be a new
+         ;; sequence but a reference to the parent
+         ;; sequence. Hence when modifying this sequence
+         ;; parent slot props will be altered as well : and it
+         ;; SHOULD NOT !
+         ;; 
+         (let* ((pslot (aref pslots i))
+                (sd (cl--copy-slot-descriptor pslot))
                  (init (car (rassq (cl--slot-descriptor-name sd) pinit))))
+           ;;
+           ;; Simply applying a `copy-sequence' on the props
+           ;; will not work since props itself is a sequence
+           ;; whose elements will not be copied and only
+           ;; reference elements of the old props plist. A
+           ;; reccursive copy should be performed.
+           ;; 
+           (setf (cl--slot-descriptor-props sd)
+                 (copy-tree
+                  (cl--slot-descriptor-props pslot)))
            (eieio--add-new-slot newc sd init nil nil sn))
+         ;; 
+         ;;;  -- End Props should be copied as well 
           )) ;; while/let
       ;; Now duplicate all the class alloc slots.
       (let ((pcslots (eieio--class-class-slots pcv)))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]