From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.emacs.bugs Subject: bug#70155: 29.3; Several Emacs Lisp list functions accept non-list arguments Date: Tue, 02 Apr 2024 19:15:28 -0400 Message-ID: <87y19v8igf.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32412"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: 70155@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Apr 03 01:16:25 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 1rrnMe-0008Bt-8o for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 03 Apr 2024 01:16:24 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rrnMG-0007DH-F8; Tue, 02 Apr 2024 19:16:00 -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 1rrnME-0007Cc-Q8 for bug-gnu-emacs@gnu.org; Tue, 02 Apr 2024 19:15:58 -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 1rrnME-0004nb-Hx for bug-gnu-emacs@gnu.org; Tue, 02 Apr 2024 19:15:58 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rrnMI-00078l-EJ for bug-gnu-emacs@gnu.org; Tue, 02 Apr 2024 19:16:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 02 Apr 2024 23:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 70155 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.171209975427430 (code B ref -1); Tue, 02 Apr 2024 23:16:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 2 Apr 2024 23:15:54 +0000 Original-Received: from localhost ([127.0.0.1]:56545 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rrnM8-00078F-Ov for submit@debbugs.gnu.org; Tue, 02 Apr 2024 19:15:53 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:53006) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rrnM6-000777-PM for submit@debbugs.gnu.org; Tue, 02 Apr 2024 19:15:51 -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 1rrnLt-0007Be-RR for bug-gnu-emacs@gnu.org; Tue, 02 Apr 2024 19:15:37 -0400 Original-Received: from mail-oo1-xc31.google.com ([2607:f8b0:4864:20::c31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rrnLq-0004lQ-3H for bug-gnu-emacs@gnu.org; Tue, 02 Apr 2024 19:15:37 -0400 Original-Received: by mail-oo1-xc31.google.com with SMTP id 006d021491bc7-5a4d3b82e53so156766eaf.0 for ; Tue, 02 Apr 2024 16:15:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712099730; x=1712704530; darn=gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :subject:to:from:from:to:cc:subject:date:message-id:reply-to; bh=2Yq3L0+WJiy86Tiu9PGRWe3cKKd+8kZGsJBAMwFa6Vk=; b=a83eEPFh7CP2vw0GEC3r7l8HDz7n+9brkHJyY1opLF6Y+ijwT4hvaYaPDy61TlU1TV EBfsdnUgBt8LS6Y8Vy0c9DIawKefYQUilhe9kk2mNSxvmwx1OCXjbDqgslv1dNkXNX13 XThm3bBFiGDU9czZf1qaC+SPkFU3N6sLcuJHnxhwSLw/THoXbL9qGSiLThcbuZyIU/+a qpW7t7X0qaU/Cr2VOngNFbsc7N6GGw50M1R0RCPP2qHVAVmB51OTz7PbXTuP+VlxoRN/ SV0gtcE3fh8jTVu5eV0uSAcv1Hcku3oOdQoO4wjUGdSbvRPIwxfhXbpj+TV/hBflbhXG M7Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712099730; x=1712704530; h=content-transfer-encoding:mime-version:user-agent:message-id:date :subject:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2Yq3L0+WJiy86Tiu9PGRWe3cKKd+8kZGsJBAMwFa6Vk=; b=UTY5TWUCZg/K/DiJSwI34BIr+iVGjzuUJ2s7k0QOGxg8WEeWts7zGVcxlvQCV4Q/tP jtn/5eKn4He1tPEvfFx4r4r3+I4lzw27vrDgZjFRA+whHW0eHAcnq64bUhv3olCx5Vkc WVE6LKuXOcmtdju++qGlUyJqhpOsUka91ZTxMbKEvFxznZNk05P5LUxvQVwL5Wf3IJnW 1JmG1vm36FcTcI0D6F03WqlYnkQEbkilmBTNoJrEqurnQGXxvF5/TJ0qlD4AwYqD+jiJ i+/0O987alUm9YDzcUOFRdZaefSmZ4MdcycqknOJC5c/X6L+KPjolkj9aLaCBIje05n6 oT3Q== X-Gm-Message-State: AOJu0YxccsxGL1JgBlVpGaMWX1ORUSlscithQzx5TOpXijE0y01tGJGE xtLMmNpKb+KZGRhxBQvIEfoHpOojIo3bz8Rhaf9+GKXF4IV5o8Jz X-Google-Smtp-Source: AGHT+IGdHQxRjbOJX6nOlbNEAuvn1WuIZAMCzJs5G9TIqoRSEu+i8R1Y0e2/w7hBuTRHCsyoxytprQ== X-Received: by 2002:a05:6870:a44c:b0:221:9381:7b47 with SMTP id n12-20020a056870a44c00b0022193817b47mr362008oal.19.1712099730360; Tue, 02 Apr 2024 16:15:30 -0700 (PDT) Original-Received: from t530.local ([2600:8806:a821:2b00::5150]) by smtp.gmail.com with ESMTPSA id fs13-20020a056870f78d00b0022e82259a09sm350226oab.40.2024.04.02.16.15.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 16:15:29 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::c31; envelope-from=tpeplt@gmail.com; helo=mail-oo1-xc31.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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:282552 Archived-At: The built-in Emacs Lisp functions =E2=80=98last=E2=80=99, =E2=80=98nthcdr= =E2=80=99, =E2=80=98take=E2=80=99, and =E2=80=98ntake=E2=80=99 are functions that accept lists as an argument. However, they also accept non-list arguments without signaling an error. This is not documented in their docstrings or in the Emacs Lisp reference manual. The behavior of the related list functions =E2=80=98butlast=E2=80=99 and =E2=80=98nbutlast=E2=80=99 is that an error is signaled when the function= =E2=80=99s list argument is not a list. If it is intended that the functions =E2=80=98last=E2=80=99, =E2=80=98nthcd= r=E2=80=99, =E2=80=98take=E2=80=99, and =E2=80=98ntake=E2=80=99 should accept non-list = arguments without signaling an error, then this should be documented. Otherwise, these functions should be changed to behave consistent with other list functions by signaling an error when an expected list argument is not a list. This behavior can be seen by following these steps: 1. Start Emacs at a shell prompt with option =E2=80=98-Q=E2=80=99: $ emacs = -Q 2. Evaluate the following expressions in the *scratch* buffer. Note that =E2=80=98last=E2=80=99 does not signal an error when = a non-list argument is provided: (last '(a b c)) ;;=3D> (c) (last 'a) ;;=3D> a (last 3.14) ;;=3D> 3.14 (last "a string") ;;=3D> "a string" 3. Evaluate following expressions with the related function =E2=80=98butlas= t=E2=80=99. Note that the function signals an error when provided a non-list argument. (butlast '(a b c)) ;;=3D> (a b) (butlast 'a) ;;=3D> *** Eval error *** Wrong type argument: sequencep, a (butlast 3.14) ;;=3D> *** Eval error *** Wrong type argument: sequencep, 3.14 (butlast "a string") ;;=3D> *** Eval error *** Wrong type argument: listp, "a string" 4. Evaluate the following expressions for =E2=80=98nthcdr=E2=80=99, =E2=80= =98take=E2=80=99, and =E2=80=98ntake=E2=80=99. As expected, an error is signaled when the (first) number argument is non-zero and the list argument is a non-list. But no error is signaled when the (first) number argument is zero and the list argument is a non-list. (nthcdr 0 '(a b c)) ;;=3D> (a b c) (correct, as documented) (nthcdr 1 'a) ;;=3D> *** Eval error *** Wrong type argument: listp, a (nthcdr 0 'a) ;;=3D> a (expect an error, but got the argument returned instead) (take 0 '(a b c)) ;;=3D> nil (correct, as documented) (take 1 'a) =3D> nil ;;=3D> *** Eval error *** Wrong type argument: listp, a (take 0 'a) ;;=3D> nil (expect an error, but got the argument returned instead) (ntake 0 '(a b c)) ;;=3D> nil (correct, as documented) (ntake 1 'a) =3D> nil ;;=3D> *** Eval error *** Wrong type argument: listp, a (ntake 0 'a) ;;=3D> nil (expect an error, but got the argument returned instead) --