From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.bugs Subject: bug#28489: Acknowledgement (27.0.50; eieio-persistent slot type validation should be a bit smarter) Date: Tue, 26 Sep 2017 13:22:50 -0700 Message-ID: <878th1i50l.fsf@ericabrahamsen.net> References: <87lglcn8dt.fsf@ericabrahamsen.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1506457421 26103 195.159.176.226 (26 Sep 2017 20:23:41 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 26 Sep 2017 20:23:41 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.60 (gnu/linux) To: 28489@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Sep 26 22:23:38 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dwwOB-00062G-By for geb-bug-gnu-emacs@m.gmane.org; Tue, 26 Sep 2017 22:23:31 +0200 Original-Received: from localhost ([::1]:51025 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwwOI-0001oO-9F for geb-bug-gnu-emacs@m.gmane.org; Tue, 26 Sep 2017 16:23:38 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47364) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwwNn-0001W2-3K for bug-gnu-emacs@gnu.org; Tue, 26 Sep 2017 16:23:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dwwNi-0007eD-6R for bug-gnu-emacs@gnu.org; Tue, 26 Sep 2017 16:23:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:53226) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dwwNh-0007e0-Vk for bug-gnu-emacs@gnu.org; Tue, 26 Sep 2017 16:23:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dwwNh-0008GV-Pg for bug-gnu-emacs@gnu.org; Tue, 26 Sep 2017 16:23:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eric Abrahamsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 26 Sep 2017 20:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28489 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 28489-submit@debbugs.gnu.org id=B28489.150645737431739 (code B ref 28489); Tue, 26 Sep 2017 20:23:01 +0000 Original-Received: (at 28489) by debbugs.gnu.org; 26 Sep 2017 20:22:54 +0000 Original-Received: from localhost ([127.0.0.1]:33674 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dwwNa-0008Fr-Fz for submit@debbugs.gnu.org; Tue, 26 Sep 2017 16:22:54 -0400 Original-Received: from mail.ericabrahamsen.net ([50.56.99.223]:47104) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dwwNZ-0008Fj-0R for 28489@debbugs.gnu.org; Tue, 26 Sep 2017 16:22:53 -0400 Original-Received: from localhost (71-35-182-76.tukw.qwest.net [71.35.182.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: eric@ericabrahamsen.net) by mail.ericabrahamsen.net (Postfix) with ESMTPSA id 528ACC0483 for <28489@debbugs.gnu.org>; Tue, 26 Sep 2017 20:22:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mail.ericabrahamsen.net; s=mail; t=1506457371; bh=k4FzxsoyhSeJllOHaCI+2UzNmYnOOA++5wc2CgtzuSk=; h=From:To:Subject:References:Date:In-Reply-To:From; b=u06+CnivEz6uTIfmpy+vz/6Db/OKEVm2e6E8TrDOD1GwIsSl3AhATpQA3cWhjt6Mg DPH7Ct98L+Two4qih/lM4tcDErhkmW3PE3SKV52WpoRkY7szDhsFzTLfoMkZRvTwO2 cbIvrOAW88VSdRY6K7DXxFl1BDr5UXcgPn/qc+NI= In-Reply-To: (GNU bug Tracking System's message of "Mon, 18 Sep 2017 00:45:02 +0000") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:137476 Archived-At: --=-=-= Content-Type: text/plain Here's a basic patch that does the bare minimum, and seems to work. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=orclasstypes.diff diff --git a/lisp/emacs-lisp/eieio-base.el b/lisp/emacs-lisp/eieio-base.el index 6b39b4f262..361c1a4eb9 100644 --- a/lisp/emacs-lisp/eieio-base.el +++ b/lisp/emacs-lisp/eieio-base.el @@ -308,14 +308,6 @@ eieio-persistent-validate/fix-slot-value (= (length proposed-value) 1)) nil) - ;; We have a slot with a single object that can be - ;; saved here. Recurse and evaluate that - ;; sub-object. - ((and classtype (class-p classtype) - (child-of-class-p (car proposed-value) classtype)) - (eieio-persistent-convert-list-to-object - proposed-value)) - ;; List of object constructors. ((and (eq (car proposed-value) 'list) ;; 2nd item is a list. @@ -346,6 +338,16 @@ eieio-persistent-validate/fix-slot-value objlist)) ;; return the list of objects ... reversed. (nreverse objlist))) + ;; We have a slot with a single object that can be + ;; saved here. Recurse and evaluate that + ;; sub-object. + ((and classtype + (seq-some + (lambda (c-type) + (child-of-class-p (car proposed-value) c-type)) + (if (listp classtype) classtype (list classtype)))) + (eieio-persistent-convert-list-to-object + proposed-value)) (t proposed-value)))) @@ -359,7 +361,7 @@ eieio-persistent-validate/fix-slot-value ) (defun eieio-persistent-slot-type-is-class-p (type) - "Return the class referred to in TYPE. + "Return the class or classes referred to in TYPE. If no class is referenced there, then return nil." (cond ((class-p type) ;; If the type is a class, then return it. @@ -402,13 +404,9 @@ eieio-persistent-slot-type-is-class-p type)) ((eq (car-safe type) 'or) - ;; If type is a list, and is an or, it is possibly something - ;; like (or null myclass), so check for that. - (let ((ans nil)) - (dolist (subtype (cdr type)) - (setq ans (eieio-persistent-slot-type-is-class-p - subtype))) - ans)) + ;; If type is a list, and is an or, it is possible that + ;; multiple classes are acceptable, find them all. + (seq-filter (lambda (elt) (class-p elt)) (cdr type))) (t ;; No match, not a class. --=-=-=--