all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: npostavs@users.sourceforge.net
Cc: 27718@debbugs.gnu.org, Alex <agrambot@gmail.com>
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	[thread overview]
Message-ID: <jwvinimexvn.fsf-monnier+emacsbugs@gnu.org> (raw)
In-Reply-To: <87inim9dy0.fsf@users.sourceforge.net> (npostavs's message of "Fri, 21 Jul 2017 08:23:03 -0400")

> 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 <npostavs@gmail.com>
> 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






  reply	other threads:[~2017-07-21 13:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-15 21:50 bug#27718: 26.0.50; (cl-typep instance-ab 'class-a) gives wrong answer when compiled npostavs
2017-07-21 12:23 ` npostavs
2017-07-21 13:19   ` Stefan Monnier [this message]
2017-07-22 17:51     ` npostavs
2017-07-24 15:30       ` Stefan Monnier
2017-07-24 19:44         ` Stefan Monnier
2017-07-25 16:34           ` Noam Postavsky
2017-07-25 21:21             ` Stefan Monnier
2017-08-05  1:06               ` npostavs
2017-08-05 12:49                 ` Stefan Monnier
2017-08-08  1:16                   ` npostavs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvinimexvn.fsf-monnier+emacsbugs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=27718@debbugs.gnu.org \
    --cc=agrambot@gmail.com \
    --cc=npostavs@users.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.