From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#47327: 28.0.50; (cl-generic) eql specializer not evaluated Date: Fri, 16 Jul 2021 17:00:17 -0400 Message-ID: References: <87k0pz5d6u.fsf@gmail.com> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17956"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 47327@debbugs.gnu.org To: akater Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 16 23:01:11 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m4UxL-0004WF-HG for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 16 Jul 2021 23:01:11 +0200 Original-Received: from localhost ([::1]:56536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4UxJ-0007Ql-VL for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 16 Jul 2021 17:01:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40170) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4UxC-0007QM-4w for bug-gnu-emacs@gnu.org; Fri, 16 Jul 2021 17:01:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40901) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m4UxB-00058N-TS for bug-gnu-emacs@gnu.org; Fri, 16 Jul 2021 17:01:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m4UxB-0006MQ-Of for bug-gnu-emacs@gnu.org; Fri, 16 Jul 2021 17:01:01 -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, 16 Jul 2021 21:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47327 X-GNU-PR-Package: emacs Original-Received: via spool by 47327-submit@debbugs.gnu.org id=B47327.162646923124407 (code B ref 47327); Fri, 16 Jul 2021 21:01:01 +0000 Original-Received: (at 47327) by debbugs.gnu.org; 16 Jul 2021 21:00:31 +0000 Original-Received: from localhost ([127.0.0.1]:52447 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m4Uwh-0006Lb-JP for submit@debbugs.gnu.org; Fri, 16 Jul 2021 17:00:31 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:14019) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m4Uwc-0006LJ-1T for 47327@debbugs.gnu.org; Fri, 16 Jul 2021 17:00:30 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id D004B1001F4; Fri, 16 Jul 2021 17:00:19 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 6EFE110008C; Fri, 16 Jul 2021 17:00:18 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1626469218; bh=kZEnzpqWVJ5nMfbEWoeYId+9PCl3ZzSWPAhQtC2wKCI=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=AO3tpdIqLswsqRedsIrb+HkPMqtYwewwcKm3oa/PmcA4HLUKH5OsVSiKGVVKZ5/zU EaEcM1yR1TWlCim/dErtApSqLNbq21c79gEeVGfpV0c1PVRb7MogDPmAC7vxCTyVfI HKl19uh9VfZdYL7yw6yo8jvyULmQiVn5U1yoT9ShVkGLOaeZl2sghMLd16mc5cZBZb LKmt6YRei6QJFjXg/S7bMPaby1gb+FSLJp8MetJwgkJ5/bCYeldn0q5BtnqdSoc2J1 Q2kar+NFIx5FxDKHAl8kKMmIQdnJadX2FTxEajy1SVW3Etfme7exi3R6sQkBMDLqXa MPT8Kp1zdwuuw== Original-Received: from alfajor (unknown [216.154.29.138]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 2C31D12053A; Fri, 16 Jul 2021 17:00:18 -0400 (EDT) In-Reply-To: <87k0pz5d6u.fsf@gmail.com> (akater's message of "Mon, 22 Mar 2021 17:08:09 +0000") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:210112 Archived-At: > #+begin_quote > The parameter specializer name ~(eql eql-specializer-form)~ > indicates that the corresponding argument must be eql to the object > that is the value of ~eql-specializer-form~ for the method to be applicable. > The ~eql-specializer-form~ is evaluated > at the time that the expansion of the defmethod macro is evaluated. > #+end_quote Oh, indeed, I completely missed that. That would be a nice improvement. Could you check to see which code would break if we made this change? The patch below seems to provide enough backward compatibility, but it would be nice to improve it so the warning is emitted at compile time via something like `macroexp-warn-and-return` so we get some kind of file&line number. Stefan diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el index 544704be38..6d23537ebd 100644 --- a/lisp/emacs-lisp/cl-generic.el +++ b/lisp/emacs-lisp/cl-generic.el @@ -1158,7 +1158,12 @@ cl--generic-eql-generalizer (cl-defmethod cl-generic-generalizers ((specializer (head eql))) "Support for (eql VAL) specializers. These match if the argument is `eql' to VAL." - (puthash (cadr specializer) specializer cl--generic-eql-used) + (let ((form (cadr specializer))) + (puthash (if (or (not (symbolp form)) (macroexp-const-p form)) + (eval form t) + (message "Quoting obsolete `eql' form: %S" specializer) + form) + specializer cl--generic-eql-used)) (list cl--generic-eql-generalizer)) (cl--generic-prefill-dispatchers 0 (eql nil)) diff --git a/test/lisp/emacs-lisp/cl-generic-tests.el b/test/lisp/emacs-lisp/cl-generic-tests.el index 9312fb44a1..b48a48fb94 100644 --- a/test/lisp/emacs-lisp/cl-generic-tests.el +++ b/test/lisp/emacs-lisp/cl-generic-tests.el @@ -56,7 +56,11 @@ cl-generic-test-01-eql (should (equal (cl--generic-1 'a nil) '(a))) (should (equal (cl--generic-1 4 nil) '("quatre" 4))) (should (equal (cl--generic-1 5 nil) '("cinq" 5))) - (should (equal (cl--generic-1 6 nil) '("six" a)))) + (should (equal (cl--generic-1 6 nil) '("six" a))) + (defvar cl--generic-fooval 41) + (cl-defmethod cl--generic-1 ((_x (eql (+ cl--generic-fooval 1))) _y) + "forty-two") + (should (equal (cl--generic-1 42 nil) "forty-two"))) (cl-defstruct cl-generic-struct-parent a b) (cl-defstruct (cl-generic-struct-child1 (:include cl-generic-struct-parent)) c)