From unknown Wed Jun 18 23:09:46 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#78607 <78607@debbugs.gnu.org> To: bug#78607 <78607@debbugs.gnu.org> Subject: Status: 31.0.50; cl-nsubstitute on strings returns an vector of integers Reply-To: bug#78607 <78607@debbugs.gnu.org> Date: Thu, 19 Jun 2025 06:09:46 +0000 retitle 78607 31.0.50; cl-nsubstitute on strings returns an vector of integ= ers reassign 78607 emacs submitter 78607 Madhu severity 78607 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Tue May 27 11:36:11 2025 Received: (at submit) by debbugs.gnu.org; 27 May 2025 15:36:11 +0000 Received: from localhost ([127.0.0.1]:42641 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uJwLa-0003QC-Tc for submit@debbugs.gnu.org; Tue, 27 May 2025 11:36:11 -0400 Received: from lists.gnu.org ([2001:470:142::17]:53820) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uJwLU-0003PN-O0 for submit@debbugs.gnu.org; Tue, 27 May 2025 11:36:08 -0400 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 1uJwLO-0003qS-7N for bug-gnu-emacs@gnu.org; Tue, 27 May 2025 11:35:59 -0400 Received: from smtp5.ctinetworks.com ([205.166.61.198]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uJwLJ-0002Fl-GL for bug-gnu-emacs@gnu.org; Tue, 27 May 2025 11:35:58 -0400 X-ctinetworks-Watermark: 1749224149.61149@9Y6bHOXUVbwRCrtGIX4yVQ X-ctinetworks-Envelope-From: enometh@meer.net X-ctinetworks-SpamCheck: X-ctinetworks-VirusCheck: Found to be clean X-ctinetworks-Message-ID: 878DD2064FD2.A3D81 Received: from localhost (unknown [117.254.37.20]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: enometh@meer.net) by smtp5.ctinetworks.com (Postfix) with ESMTPSA id 878DD2064FD2 for ; Tue, 27 May 2025 11:35:48 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp5.ctinetworks.com 878DD2064FD2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meer.net; s=ctidkims1; t=1748360149; bh=GEk1dBrsOdTF4l+UAUQXr8qlvfu5Bd7zijbhcx/5zBA=; h=Date:To:Subject:From:From; b=Li5oBEi166SVg0rikct3tBmf4eNHD5cF5TvHBIcSa8HGLE5v3KLqHEQw3BvXGGhD6 HcHB+d5N86O51Ms5ndwMskxH74gNsVCs0PiO0ejsLJvcNg8req7rkRG73thETaOLLy DzVrbkadNNJym5Wg2y89RZZH+dcXPBAxnKS+3KIo= Date: Tue, 27 May 2025 21:06:02 +0530 (IST) Message-Id: <20250527.210602.2259042123383956129.enometh@meer.net> To: bug-gnu-emacs@gnu.org Subject: 31.0.50; cl-nsubstitute on strings returns an vector of integers From: Madhu X-Mailer: Mew version 6.9 on Emacs 31.0.50 Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Tue_May_27_21_06_02_2025_893)--" Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=205.166.61.198; envelope-from=enometh@meer.net; helo=smtp5.ctinetworks.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) ----Next_Part(Tue_May_27_21_06_02_2025_893)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit On recent master: (cl-substitute ?\_ ?\/ "foo/bar") => [102 111 111 95 98 97 114] But this should return: "foo_bar" This seems to be a bug in commit 8c8ff13e "Clean up 'cl-' prefixes for local variables", which replaced variable names without considering the semantics. In this case the cl-seq was being used to name a new variable to distinguish it from `seq' -- see attached patch. [The commit that introduced the semantically significant variable is de5a89254 "Don't mutate strings in cl-substitute" The point of the `n' in nsubstitute is to mark the function as one that possibly mutates its argument, (when the implementation judges that is more efficient and the user prefers to reuse string storage rather than copy it) https://www.lispworks.com/documentation/HyperSpec/Body/f_sbs_s.htm I haven't understand this commit message yet but I hope it does not preculde a comprehension of the semantics of the "n!"-variant.] -- Madhu ----Next_Part(Tue_May_27_21_06_02_2025_893)-- Content-Type: Text/X-Patch; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="0001-lisp-emacs-lisp-cl-seq.el-fix-previous-commit.patch" >From 73d75d55990059db34f0e4bfc420d7bb14e180dd Mon Sep 17 00:00:00 2001 From: Madhu Date: Tue, 27 May 2025 21:02:09 +0530 Subject: [PATCH] lisp/emacs-lisp/cl-seq.el: fix previous commit lisp/emacs-lisp/cl-seq.el: (nsubstitute): restore a variable names that were incorrectly replaced in commit 8c8ff13e, so nsubstitute on a string returns a string instead of a vector --- lisp/emacs-lisp/cl-seq.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/emacs-lisp/cl-seq.el b/lisp/emacs-lisp/cl-seq.el index 33f14df0291..c267995a79d 100644 --- a/lisp/emacs-lisp/cl-seq.el +++ b/lisp/emacs-lisp/cl-seq.el @@ -469,7 +469,7 @@ cl-nsubstitute (declare (important-return-value t)) (cl--parsing-keywords ( :test :test-not :key :if :if-not :count (:start 0) :end :from-end) () - (let* ((seq (if (stringp seq) (string-to-vector seq) seq)) + (let* ((cl-seq (if (stringp seq) (string-to-vector seq) seq)) (len (length seq))) (or (eq old new) (<= (or cl-count (setq cl-count len)) 0) (if (and (listp seq) (or (not cl-from-end) (> cl-count (/ len 2)))) @@ -495,7 +495,7 @@ cl-nsubstitute (aset seq cl-start new) (setq cl-count (1- cl-count)))) (setq cl-start (1+ cl-start)))))) - (if (stringp seq) (concat seq) seq)))) + (if (stringp cl-seq) (concat seq) seq)))) ;;;###autoload (defun cl-nsubstitute-if (new pred list &rest cl-keys) -- 2.49.0.9.gd50a5e8939.dirty ----Next_Part(Tue_May_27_21_06_02_2025_893)---- From debbugs-submit-bounces@debbugs.gnu.org Tue May 27 11:43:57 2025 Received: (at submit) by debbugs.gnu.org; 27 May 2025 15:43:57 +0000 Received: from localhost ([127.0.0.1]:42695 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uJwT6-0003vt-Ek for submit@debbugs.gnu.org; Tue, 27 May 2025 11:43:56 -0400 Received: from lists.gnu.org ([2001:470:142::17]:43462) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uJwT2-0003vI-UF for submit@debbugs.gnu.org; Tue, 27 May 2025 11:43:54 -0400 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 1uJwSx-0006Kw-Aa for bug-gnu-emacs@gnu.org; Tue, 27 May 2025 11:43:47 -0400 Received: from ciao.gmane.io ([116.202.254.214]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uJwSm-0003C3-Aj for bug-gnu-emacs@gnu.org; Tue, 27 May 2025 11:43:47 -0400 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1uJwSX-0000rf-Qf for bug-gnu-emacs@gnu.org; Tue, 27 May 2025 17:43:21 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: bug-gnu-emacs@gnu.org From: Madhu Subject: Re: bug#78607: 31.0.50; cl-nsubstitute on strings returns an vector of integers Date: Tue, 27 May 2025 21:13:33 +0530 Message-ID: References: <20250527.210602.2259042123383956129.enometh@meer.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Cancel-Lock: sha1:OyDg72DrhwR59wJ0OLX3UOt98Sk= Received-SPF: pass client-ip=116.202.254.214; envelope-from=geb-bug-gnu-emacs@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain The patch I supplied is of course wrong: it did the same "blind replace" refactoring and got it wrong (skitts law in programming), the attached patch is uglier but hopefully is semantically correct --Madhu --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-lisp-emacs-lisp-cl-seq.el-fix-previous-commit.patch Content-Description: fix previous patch >From 4ca663d377c2c4c9f2da890ac797f9575b9ae947 Mon Sep 17 00:00:00 2001 From: Madhu Date: Tue, 27 May 2025 21:02:09 +0530 Subject: [PATCH] lisp/emacs-lisp/cl-seq.el: fix previous commit lisp/emacs-lisp/cl-seq.el: (nsubstitute): restore a variable names that were incorrectly replaced in commit 8c8ff13e, so nsubstitute on a string returns a string instead of a vector --- lisp/emacs-lisp/cl-seq.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/emacs-lisp/cl-seq.el b/lisp/emacs-lisp/cl-seq.el index 33f14df0291..996aa7d453a 100644 --- a/lisp/emacs-lisp/cl-seq.el +++ b/lisp/emacs-lisp/cl-seq.el @@ -469,7 +469,8 @@ cl-nsubstitute (declare (important-return-value t)) (cl--parsing-keywords ( :test :test-not :key :if :if-not :count (:start 0) :end :from-end) () - (let* ((seq (if (stringp seq) (string-to-vector seq) seq)) + (let* ((stringp (stringp seq)) + (seq (if (stringp seq) (string-to-vector seq) seq)) (len (length seq))) (or (eq old new) (<= (or cl-count (setq cl-count len)) 0) (if (and (listp seq) (or (not cl-from-end) (> cl-count (/ len 2)))) @@ -495,7 +496,7 @@ cl-nsubstitute (aset seq cl-start new) (setq cl-count (1- cl-count)))) (setq cl-start (1+ cl-start)))))) - (if (stringp seq) (concat seq) seq)))) + (if stringp (concat seq) seq)))) ;;;###autoload (defun cl-nsubstitute-if (new pred list &rest cl-keys) -- 2.49.0.9.gd50a5e8939.dirty --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat May 31 07:38:40 2025 Received: (at 78607) by debbugs.gnu.org; 31 May 2025 11:38:40 +0000 Received: from localhost ([127.0.0.1]:56378 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uLKXv-0005Rh-ST for submit@debbugs.gnu.org; Sat, 31 May 2025 07:38:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49182) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uLKXt-0005Qv-Q1 for 78607@debbugs.gnu.org; Sat, 31 May 2025 07:38:38 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uLKXo-0008Ry-8H; Sat, 31 May 2025 07:38:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=XMcKDdzWZEESodzuMtH0JI1TzwJiAca3hx5vwl6AwiM=; b=YngMfp1VGNOC x3NwY2WXvaDboDqXTqVSVEqIvLX3G+vp+o3sEoo0pBtEYML53BrI7SRdwVjc6vwXT9sVn/Z0C3OUM nivfw5xK3N3J4dGjsgDGRrFdbqPJ0hdkdYoXz/Ik+ziJHzMIRwUBek5IAJM8phb2cypacrxRo++cQ UZJPDOsFX0m62+eJlWmpLVlx3miFmg0ZljxkB82sJnjhKl81x7PxG/jKgthgpssf0EpdQuR61k7l8 jB8nYvQCe2dBDLhX58kfFOv7SwToTvBYGZAFoe6r9RH25eC4U6nHK+4Q0cj9Mb+GeEXeQFvert89k aC6l4q09fuOsr7pEmkpvow==; Date: Sat, 31 May 2025 14:38:05 +0300 Message-Id: <868qmdrowy.fsf@gnu.org> From: Eli Zaretskii To: Madhu , Stefan Kangas In-Reply-To: <20250527.210602.2259042123383956129.enometh@meer.net> (message from Madhu on Tue, 27 May 2025 21:06:02 +0530 (IST)) Subject: Re: bug#78607: 31.0.50; cl-nsubstitute on strings returns an vector of integers References: <20250527.210602.2259042123383956129.enometh@meer.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78607 Cc: 78607@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Tue, 27 May 2025 21:06:02 +0530 (IST) > From: Madhu > > On recent master: > > (cl-substitute ?\_ ?\/ "foo/bar") > > => [102 111 111 95 98 97 114] > > But this should return: "foo_bar" > > This seems to be a bug in commit 8c8ff13e "Clean up 'cl-' prefixes for > local variables", which replaced variable names without considering > the semantics. In this case the cl-seq was being used to name a new > variable to distinguish it from `seq' -- see attached patch. > > [The commit that introduced the semantically significant variable is > de5a89254 "Don't mutate strings in cl-substitute" > > The point of the `n' in nsubstitute is to mark the function as one > that possibly mutates its argument, (when the implementation judges > that is more efficient and the user prefers to reuse string storage > rather than copy it) > > https://www.lispworks.com/documentation/HyperSpec/Body/f_sbs_s.htm > > I haven't understand this commit message yet but I hope it does not > preculde a comprehension of the semantics of the "n!"-variant.] -- Madhu > > >From 73d75d55990059db34f0e4bfc420d7bb14e180dd Mon Sep 17 00:00:00 2001 > From: Madhu > Date: Tue, 27 May 2025 21:02:09 +0530 > Subject: [PATCH] lisp/emacs-lisp/cl-seq.el: fix previous commit > > lisp/emacs-lisp/cl-seq.el: (nsubstitute): restore a variable names that > were incorrectly replaced in commit 8c8ff13e, so nsubstitute on a string > returns a string instead of a vector > --- > lisp/emacs-lisp/cl-seq.el | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/lisp/emacs-lisp/cl-seq.el b/lisp/emacs-lisp/cl-seq.el > index 33f14df0291..c267995a79d 100644 > --- a/lisp/emacs-lisp/cl-seq.el > +++ b/lisp/emacs-lisp/cl-seq.el > @@ -469,7 +469,7 @@ cl-nsubstitute > (declare (important-return-value t)) > (cl--parsing-keywords ( :test :test-not :key :if :if-not :count > (:start 0) :end :from-end) () > - (let* ((seq (if (stringp seq) (string-to-vector seq) seq)) > + (let* ((cl-seq (if (stringp seq) (string-to-vector seq) seq)) > (len (length seq))) > (or (eq old new) (<= (or cl-count (setq cl-count len)) 0) > (if (and (listp seq) (or (not cl-from-end) (> cl-count (/ len 2)))) > @@ -495,7 +495,7 @@ cl-nsubstitute > (aset seq cl-start new) > (setq cl-count (1- cl-count)))) > (setq cl-start (1+ cl-start)))))) > - (if (stringp seq) (concat seq) seq)))) > + (if (stringp cl-seq) (concat seq) seq)))) > > ;;;###autoload > (defun cl-nsubstitute-if (new pred list &rest cl-keys) > -- Stefan, any comments?