From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: npostavs@users.sourceforge.net Newsgroups: gmane.emacs.bugs Subject: bug#27718: 26.0.50; (cl-typep instance-ab 'class-a) gives wrong answer when compiled Date: Fri, 21 Jul 2017 08:23:03 -0400 Message-ID: <87inim9dy0.fsf@users.sourceforge.net> References: <87tw2dcqtz.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1500639743 14815 195.159.176.226 (21 Jul 2017 12:22:23 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 21 Jul 2017 12:22:23 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) Cc: Stefan Monnier , Alex To: 27718@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jul 21 14:22:17 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 1dYWwd-0003EG-84 for geb-bug-gnu-emacs@m.gmane.org; Fri, 21 Jul 2017 14:22:11 +0200 Original-Received: from localhost ([::1]:42824 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dYWwh-0007bB-B0 for geb-bug-gnu-emacs@m.gmane.org; Fri, 21 Jul 2017 08:22:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51960) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dYWwZ-0007at-Vr for bug-gnu-emacs@gnu.org; Fri, 21 Jul 2017 08:22:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dYWwU-0000Lu-W4 for bug-gnu-emacs@gnu.org; Fri, 21 Jul 2017 08:22:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:47763) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dYWwU-0000Lo-Qx for bug-gnu-emacs@gnu.org; Fri, 21 Jul 2017 08:22:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dYWwU-000376-IU for bug-gnu-emacs@gnu.org; Fri, 21 Jul 2017 08:22:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 21 Jul 2017 12:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27718 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 27718-submit@debbugs.gnu.org id=B27718.150063970011940 (code B ref 27718); Fri, 21 Jul 2017 12:22:02 +0000 Original-Received: (at 27718) by debbugs.gnu.org; 21 Jul 2017 12:21:40 +0000 Original-Received: from localhost ([127.0.0.1]:50440 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dYWw8-00036V-1t for submit@debbugs.gnu.org; Fri, 21 Jul 2017 08:21:40 -0400 Original-Received: from mail-it0-f47.google.com ([209.85.214.47]:37840) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dYWw5-000368-Ju; Fri, 21 Jul 2017 08:21:38 -0400 Original-Received: by mail-it0-f47.google.com with SMTP id v127so6505018itd.0; Fri, 21 Jul 2017 05:21:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=3WRDQv/D9YEDnoOeSVNG21NQJTbvcyKFvQJ0i8/CgQM=; b=TNMmm6cluYH/GREgontoYS2JRdwF0BvJ2De6MHwJtxfy8HjR6Tplc/KUsXSGVTFcSG D1WcqGosaWMdgFprXZ0Pfz07L151edAap0wBBDfgao+Qs1wBIhGmnWiK7Lx5U+B7QrZw /mACzNA53GB9G0bTo4myNUsz9teiKGx/rVsNaguNazXjvDINL/l5DJaL9gjDheE+w3ed 4t379GTX9iQTWAjsMoUZr6Yj3vr2O7xZ/3wUTe+LStBA4PPvXjJtBYD9Y68TXERWsfUR WX7Ty1nd196FCxjZyUDs6u7cUfIBusaS6Ry2fnIePIXV0b+eY09C6Eo/BsUkqi+Hh+II rnNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=3WRDQv/D9YEDnoOeSVNG21NQJTbvcyKFvQJ0i8/CgQM=; b=Mcx47eb63PXBnKdgrk5JFqeJvskBjoejojsYrQPXXlzKtzmo8PvgLgpZh1q7YkpDdb ay8eGe4lhWURhoqP1jeyQbmrIGBR8cx5Z1rmLF/G95y0V9uMinZtif5xtukYyUGjsT/2 rM7TU62MTwTSjL6fY+oloNfh1gV413f/QDUdiOroREDZGEkQEX4uRuelJNSb9K5ioAXF nFn+lcL6WxiQFi/V5b0/NAZs67kNvep6F/VioDYuEDCl1N5FXFbmWoabvdbvy7iJX8Uf xquxVcjPTydOrCiPXXJ/9Kyqv+voXJlbuQ4nWzCS4giJ8Va2DHf/zZZRIq1AIG0dTQ6p QCtw== X-Gm-Message-State: AIVw112rbupuat4xFgUIRHtpv83JBdOUgivQuRgGpSgmcXyk04WIXEg/ dxTIahgOaBAptxaa X-Received: by 10.36.92.77 with SMTP id q74mr6897338itb.24.1500639691681; Fri, 21 Jul 2017 05:21:31 -0700 (PDT) Original-Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id t131sm166972itb.0.2017.07.21.05.21.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Jul 2017 05:21:30 -0700 (PDT) In-Reply-To: <87tw2dcqtz.fsf@users.sourceforge.net> (npostavs@users.sourceforge.net's message of "Sat, 15 Jul 2017 17:50:32 -0400") 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:134822 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable tags 27718 + patch quit npostavs@users.sourceforge.net writes: > ~/src/emacs$ .../emacs -Q -batch -f batch-byte-compile cl-typep-subcl= ass.el > ~/src/emacs$ .../emacs -Q -batch -l cl-typep-subclass.el > (cl-typep eitest-ab =E2=80=99class-a) =3D> t > ~/src/emacs$ .../emacs -Q -batch -l cl-typep-subclass.elc > (cl-typep eitest-ab =E2=80=99class-a) =3D> nil lisp/emacs-lisp/eieio.el:260: (defmacro defclass (name superclasses slots &rest options-and-doc) ... ;; When using typep, (typep OBJ 'myclass) returns t for objects = which ;; are subclasses of myclass. For our predicates, however, it is ;; important for EIEIO to be backwards compatible, where ;; myobject-p, and myobject-child-p are different. ;; "cl" uses this technique to specify symbols with specific typ= ep ;; test, so we can let typep have the CLOS documented behavior ;; while keeping our above predicate clean. (put ',name 'cl-deftype-satisfies #',testsym2) The problem is that the `put' doesn't take effect until runtime, so the compiler inlines `cl-typep' incorrectly. Using `function-put' here (and `function-get' in `cl-typep') solves it (requires also the patches for #27016[1]), although it seems a bit coincidental that `class-a' happens to be a function as well, so I'm not sure if this is the right thing. Stefan, any thoughts? --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v1-0001-Fix-cl-typep-instance-ab-class-a-compilation-Bug-.patch Content-Description: patch >From 4ea34c9da04c8eabc754f2ca64ef4e2ac7c59cac Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Fri, 21 Jul 2017 07:59:21 -0400 Subject: [PATCH v1] Fix (cl-typep instance-ab 'class-a) compilation (Bug#27718) Using `function-put' instead of `put' for the `cl-deftype-satisfies' property lets the compiler know about it while compiling the file so that any calls to `cl-typep' will be inlined correctly. * lisp/emacs-lisp/eieio.el (defclass): Use `function-put' for the `cl-deftype-satisfies' property. * lisp/emacs-lisp/cl-macs.el (cl-typep): Also use `function-get' to check the 'cl-deftype-satisfies' property. --- lisp/emacs-lisp/cl-macs.el | 7 +++++-- lisp/emacs-lisp/eieio.el | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 451e6490d7..f5a4f99aad 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -2991,8 +2991,11 @@ (define-inline cl-typep (val type) ((and (pred symbolp) type (guard (get type 'cl-deftype-handler))) (inline-quote (cl-typep ,val ',(funcall (get type 'cl-deftype-handler))))) - ((and (pred symbolp) type (guard (get type 'cl-deftype-satisfies))) - (inline-quote (funcall #',(get type 'cl-deftype-satisfies) ,val))) + ((and (pred symbolp) type (guard (or (function-get type 'cl-deftype-satisfies) + (get type 'cl-deftype-satisfies)))) + (inline-quote (funcall #',(or (function-get type 'cl-deftype-satisfies) + (Get type 'cl-deftype-satisfies)) + ,val))) ((and (or 'nil 't) type) (inline-quote ',type)) ((and (pred symbolp) type) (let* ((name (symbol-name type)) diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el index 1a7de55fce..2c333c16f4 100644 --- a/lisp/emacs-lisp/eieio.el +++ b/lisp/emacs-lisp/eieio.el @@ -246,7 +246,7 @@ (defmacro defclass (name superclasses slots &rest options-and-doc) ;; test, so we can let typep have the CLOS documented behavior ;; while keeping our above predicate clean. - (put ',name 'cl-deftype-satisfies #',testsym2) + (function-put ',name 'cl-deftype-satisfies #',testsym2) (eieio-defclass-internal ',name ',superclasses ',slots ',options-and-doc) -- 2.11.1 --=-=-= Content-Type: text/plain > You can see that tests 23 and 24 will fail when you do 'make > eieio-tests TEST_LOAD_EL=no'. This actually isn't true until the patch for #24402[2] is applied. [1]: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27016#140 [2]: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=24402#71 --=-=-=--