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: 27.0.50; eieio-persistent slot type validation should be a bit smarter Date: Sun, 17 Sep 2017 17:43:58 -0700 Message-ID: <87lglcn8dt.fsf@ericabrahamsen.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1505695519 7250 195.159.176.226 (18 Sep 2017 00:45:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 18 Sep 2017 00:45:19 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: 28489@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Sep 18 02:45:12 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 1dtkBR-0001Ub-Hy for geb-bug-gnu-emacs@m.gmane.org; Mon, 18 Sep 2017 02:45:09 +0200 Original-Received: from localhost ([::1]:34127 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtkBY-0007r0-RH for geb-bug-gnu-emacs@m.gmane.org; Sun, 17 Sep 2017 20:45:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53656) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtkBP-0007ps-1d for bug-gnu-emacs@gnu.org; Sun, 17 Sep 2017 20:45:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtkBK-0004m7-UN for bug-gnu-emacs@gnu.org; Sun, 17 Sep 2017 20:45:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:36714) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dtkBK-0004lC-PP for bug-gnu-emacs@gnu.org; Sun, 17 Sep 2017 20:45:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dtkBK-0006WD-Ex for bug-gnu-emacs@gnu.org; Sun, 17 Sep 2017 20:45:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eric Abrahamsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 18 Sep 2017 00:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 28489 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.150569546424990 (code B ref -1); Mon, 18 Sep 2017 00:45:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 18 Sep 2017 00:44:24 +0000 Original-Received: from localhost ([127.0.0.1]:45395 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dtkAh-0006V0-Pi for submit@debbugs.gnu.org; Sun, 17 Sep 2017 20:44:23 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:34202) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dtkAf-0006Um-LH for submit@debbugs.gnu.org; Sun, 17 Sep 2017 20:44:21 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtkAZ-0004LE-Gs for submit@debbugs.gnu.org; Sun, 17 Sep 2017 20:44:16 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:56116) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtkAZ-0004L4-Dk for submit@debbugs.gnu.org; Sun, 17 Sep 2017 20:44:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtkAW-0007lg-En for bug-gnu-emacs@gnu.org; Sun, 17 Sep 2017 20:44:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtkAR-0004EI-FR for bug-gnu-emacs@gnu.org; Sun, 17 Sep 2017 20:44:12 -0400 Original-Received: from mail.ericabrahamsen.net ([50.56.99.223]:50374) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtkAR-00048u-9w for bug-gnu-emacs@gnu.org; Sun, 17 Sep 2017 20:44:07 -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 21D07BFA62 for ; Mon, 18 Sep 2017 00:43:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mail.ericabrahamsen.net; s=mail; t=1505695439; bh=2GwW0WLsWji7R2Ztoyqv/v3GoW4Ono4cLb/Sv5v6lKo=; h=From:To:Subject:Date:From; b=Gfzmif68DHV7CbzbmEpXRXuNuu3cmJBDM+u5TOkq3mLI6cIBc6Iib3l9gxart2L9W x7iHL2dTdcXDFeiXYI58EGeTNzLO5RZufDSMk6vgrr5Bdg1LwYQee1KLtNiWua7PV1 wUCwliIkzMG4PYnezBnnbBu1Pfdjry2R88wDB5lA= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x 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:137042 Archived-At: EIEIO object slots can have a :type that looks like "(or thing1 thing2 ...)", meaning, obviously, that the value of the slot is legal if it is of any of those types. `eieio-persistent-validate/fix-slot-value' makes a first pass over the slot type specification, to see if any of the "things" are class symbols. The checking is done by `eieio-persistent-slot-type-is-class-p', which is able to handle an `or' statement. The bug comes with: ((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)) In effect, only the last element of the `or' statement is checked, which is obviously a bug. The Right Thing would probably be to return all the valid class types in the list (with `seq-filter' or its equivalent), and then change the rest of the code to accept that list. Otherwise, the spec and value get passed to `cl-typep' directly, which would successfully validate, except that "value" is still an object construction form, not a constructed object. It just seems like there's a lot of overlap between this and `cl-typep'. And, coincidentally, I'm getting bug reports about the very slow performance of `eieio-persistent-read'! I wonder if `cl-typep' could be taught to handle some more of these cases. The minimum fix seems to be to have `eieio-persistent-slot-type-is-class-p' return a list of classes when necessary. I can take a whack at a patch for that, if acceptable. In GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.21) of 2017-09-17 built on clem