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#69832: 30.0.50; Should `subr-primitive-p` apply to special-forms? Date: Sat, 16 Mar 2024 15:30:01 -0400 Message-ID: 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="5855"; mail-complaints-to="usenet@ciao.gmane.io" Cc: monnier@iro.umontreal.ca To: 69832@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Mar 16 20:31:45 2024 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 1rlZku-0001K5-1D for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 16 Mar 2024 20:31:44 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rlZkc-0003FP-BT; Sat, 16 Mar 2024 15:31:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rlZkb-0003Dh-Ei for bug-gnu-emacs@gnu.org; Sat, 16 Mar 2024 15:31:25 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rlZkb-0000Cv-67 for bug-gnu-emacs@gnu.org; Sat, 16 Mar 2024 15:31:25 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rlZlB-0002K8-SN; Sat, 16 Mar 2024 15:32:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: monnier@iro.umontreal.ca, bug-gnu-emacs@gnu.org Resent-Date: Sat, 16 Mar 2024 19:32:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 69832 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: monnier@iro.umontreal.ca Original-Received: via spool by submit@debbugs.gnu.org id=B.17106174668853 (code B ref -1); Sat, 16 Mar 2024 19:32:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 16 Mar 2024 19:31:06 +0000 Original-Received: from localhost ([127.0.0.1]:56461 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rlZkI-0002Ii-20 for submit@debbugs.gnu.org; Sat, 16 Mar 2024 15:31:06 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:42008) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rlZkG-0002Ia-21 for submit@debbugs.gnu.org; Sat, 16 Mar 2024 15:31:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rlZje-000369-AA for bug-gnu-emacs@gnu.org; Sat, 16 Mar 2024 15:30:26 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rlZjb-0008VD-Kn for bug-gnu-emacs@gnu.org; Sat, 16 Mar 2024 15:30:26 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 97BE71000DD for ; Sat, 16 Mar 2024 15:30:21 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1710617416; bh=dLO2Fi6iG90vMhg5XkV+E427X88WYhSeGAavS+9zszY=; h=From:To:Subject:Date:From; b=nECiu10xO3iRgpgVlrFIyq6Q0P0kE2F0a8QGkMQepnh+S2hnyuoy8zdv9edqlA1vc +bxp4bmKHvuONI5tr7wCp8aJJtdNwAIOcmGdf6zcIBCD4GfJDPg45MmwtNyMsPyPVN 0fT6bJIvsIuOzXckQvO+gcYAfaCAmanZE9l6/94weKAJo9dQpbuKUAPxurcWRSfcpK Khn98IAXLYP/6BezxQpxmqaafEcuPeTAjBRLUKlHrAKAYZwY2N1P0TQECuw2rsLddS cDFX031hMiMGAXq6Yq8UUhL7p+sHbZoef2pt7PGCbCAcawtjReEJHIDUUoHSFdwIIz sOjjIzlnp9mZQ== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 12321100048 for ; Sat, 16 Mar 2024 15:30:16 -0400 (EDT) Original-Received: from pastel (unknown [104.247.232.89]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id EEDCE12044C for ; Sat, 16 Mar 2024 15:30:15 -0400 (EDT) Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:281733 Archived-At: Package: Emacs Version: 30.0.50 Currently (subr-primitive-p (symbol-function 'if)) returns t. Its docstring disagrees: Return t if OBJECT is a built-in primitive function. because `if` is indeed a "built-in primitive" but not a "function" (you can't `funcall` it and it is rejected by `functionp`: it's a special form instead). For ELisp's type hierarchy/DAG we need a type for "a built-in primitive which is also a function". Originally, based on the docstring, I thought I could use `subr-primitive`. But it turns out that the code doesn't quite match the docstring. I can see two ways to fix that: - Introduce a new type, says `subr-function(-p)` which returns non-nil if and only if the argument is a built-in primitive *and* a function. - Change the implementation of `subr-primitive-p` to match its docstring. The patch below does the second (including changing the only place I found that wants the current semantics. Comments? Objections? Stefan diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el index 411602ef166..3458ace1c08 100644 --- a/lisp/emacs-lisp/find-func.el +++ b/lisp/emacs-lisp/find-func.el @@ -552,7 +552,7 @@ find-function-library (cons function (cond ((autoloadp def) (nth 1 def)) - ((subr-primitive-p def) + ((or (subr-primitive-p def) (special-form-p def)) (if lisp-only (error "%s is a built-in function" function)) (help-C-file-name def 'subr)) diff --git a/lisp/subr.el b/lisp/subr.el index 38a3f6edb34..f403369f534 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -315,7 +315,8 @@ subr-primitive-p "Return t if OBJECT is a built-in primitive function." (declare (side-effect-free error-free)) (and (subrp object) - (not (subr-native-elisp-p object)))) + (not (or (subr-native-elisp-p object) + (special-form-p object))))) (defsubst xor (cond1 cond2) "Return the boolean exclusive-or of COND1 and COND2.