From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier 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 09:19:58 -0400 Message-ID: References: <87tw2dcqtz.fsf@users.sourceforge.net> <87inim9dy0.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1500643276 7280 195.159.176.226 (21 Jul 2017 13:21:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 21 Jul 2017 13:21:16 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: 27718@debbugs.gnu.org, Alex To: npostavs@users.sourceforge.net Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jul 21 15:21: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 1dYXrj-0001ao-9T for geb-bug-gnu-emacs@m.gmane.org; Fri, 21 Jul 2017 15:21:11 +0200 Original-Received: from localhost ([::1]:43188 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dYXrp-00086y-0r for geb-bug-gnu-emacs@m.gmane.org; Fri, 21 Jul 2017 09:21:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38086) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dYXrd-00086h-Tr for bug-gnu-emacs@gnu.org; Fri, 21 Jul 2017 09:21:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dYXra-0002x3-PJ for bug-gnu-emacs@gnu.org; Fri, 21 Jul 2017 09:21:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:47800) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dYXra-0002wv-LA for bug-gnu-emacs@gnu.org; Fri, 21 Jul 2017 09:21:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dYXra-0006Ga-FM for bug-gnu-emacs@gnu.org; Fri, 21 Jul 2017 09:21:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 21 Jul 2017 13:21: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: patch Original-Received: via spool by 27718-submit@debbugs.gnu.org id=B27718.150064320824005 (code B ref 27718); Fri, 21 Jul 2017 13:21:02 +0000 Original-Received: (at 27718) by debbugs.gnu.org; 21 Jul 2017 13:20:08 +0000 Original-Received: from localhost ([127.0.0.1]:50477 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dYXqh-0006F7-WB for submit@debbugs.gnu.org; Fri, 21 Jul 2017 09:20:08 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:37861) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dYXqf-0006EQ-3K for 27718@debbugs.gnu.org; Fri, 21 Jul 2017 09:20:06 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DZDwCi/nFZ/9vnr2xcHAEBBAEBCgEBg1pkgRSDKIVXhgCQcywBR4c7j2cshRUEAgKDfkQUAQIBAQEBAQEBayhCEAGERQEBAQECAVYjBQsLEQMBAh0SFA0LDRYhihcDDQgQsGSHOw2DWwEBAQEBAQEDAQEBAQEeBYMohS6CcDSCV0+HOAWQXY4zPIdLh2CQEIcWjBCID4FENiGBCjEhCDCGEYFqJDYBgxqGbAEBAQ X-IPAS-Result: A0DZDwCi/nFZ/9vnr2xcHAEBBAEBCgEBg1pkgRSDKIVXhgCQcywBR4c7j2cshRUEAgKDfkQUAQIBAQEBAQEBayhCEAGERQEBAQECAVYjBQsLEQMBAh0SFA0LDRYhihcDDQgQsGSHOw2DWwEBAQEBAQEDAQEBAQEeBYMohS6CcDSCV0+HOAWQXY4zPIdLh2CQEIcWjBCID4FENiGBCjEhCDCGEYFqJDYBgxqGbAEBAQ X-IronPort-AV: E=Sophos;i="5.40,390,1496116800"; d="scan'208";a="320920884" Original-Received: from 108-175-231-219.dsl.teksavvy.com (HELO pastel.home) ([108.175.231.219]) by smtp.teksavvy.com with ESMTP; 21 Jul 2017 09:19:58 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id B020F641C1; Fri, 21 Jul 2017 09:19:58 -0400 (EDT) In-Reply-To: <87inim9dy0.fsf@users.sourceforge.net> (npostavs's message of "Fri, 21 Jul 2017 08:23:03 -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:134827 Archived-At: > 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? Hmm... I agree that using the same approach as that of bug#27016 is right, but indeed `name` doesn't refer to a function but to the name of a type (the property doesn't apply to the value stored in the symbol-function cell and shouldn't follow alias definitions). So maybe rather than hijack function-get/put in bug#27016, we should introduce a new "definitional put" with a corresponding `get`, and then use that here as well as in function-put/get. Maybe we could simply change put&get directly without introducing yet-another slightly different get/put? Stefan > 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 >> 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