From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#62761: ruby-add-log-current-method drops some segments when singleton definition references outer module Date: Tue, 11 Apr 2023 08:51:18 +0300 Message-ID: <83bkjvarvt.fsf@gnu.org> References: <9d81bdc8-355d-7d32-8d3c-361ea0ff585c@gutov.dev> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30092"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 62761@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Apr 11 07:51:26 2023 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 1pm6uc-0007cC-H0 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 11 Apr 2023 07:51:26 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pm6uG-0003kZ-Iz; Tue, 11 Apr 2023 01:51:04 -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 1pm6uE-0003jg-Dn for bug-gnu-emacs@gnu.org; Tue, 11 Apr 2023 01:51:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pm6uE-00021L-5P for bug-gnu-emacs@gnu.org; Tue, 11 Apr 2023 01:51:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pm6uE-0005vv-0r for bug-gnu-emacs@gnu.org; Tue, 11 Apr 2023 01:51:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 11 Apr 2023 05:51:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62761 X-GNU-PR-Package: emacs Original-Received: via spool by 62761-submit@debbugs.gnu.org id=B62761.168119224522697 (code B ref 62761); Tue, 11 Apr 2023 05:51:01 +0000 Original-Received: (at 62761) by debbugs.gnu.org; 11 Apr 2023 05:50:45 +0000 Original-Received: from localhost ([127.0.0.1]:36366 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pm6tx-0005tz-BO for submit@debbugs.gnu.org; Tue, 11 Apr 2023 01:50:45 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:51250) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pm6tv-0005t7-CS for 62761@debbugs.gnu.org; Tue, 11 Apr 2023 01:50:44 -0400 Original-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 1pm6tp-0001tZ-9w; Tue, 11 Apr 2023 01:50:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=wnFe+2+dTCzCiEFQBBbC3sQocWGbuUulEJC4AtsG9Lk=; b=aU41qFNKwJ02DKhye0wR aitrT57dycex3chWxdlagLur9kzxs7DKiOUaz9zL8SBEtgcTQ/bzsFnA74iiWop3EwnC/t7Wr+ZP/ Y4PLm+8HAl0/uGuI61Mzv6EG1KbqwcQ0tDmIusJOom5rn+P7XzErKoeDHRwHiCUfwVXy+xYtOirHa NQL2vSuYVrinPdOlGDocGOoxRR0IlYfJJy0mSsSGggvWUTuSJyQjkao9bh5LALfKIOKYxmbxRuUTs ruOdppgksm5ptm/9Id1SGlO/UiWGDwyCmKj2NdS61aBPiIWVMofJz3U1UVu6bUjDBifj62ceE53Ji 86ffyhb+ZRtCcQ==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pm6to-0007bi-PY; Tue, 11 Apr 2023 01:50:37 -0400 In-Reply-To: <9d81bdc8-355d-7d32-8d3c-361ea0ff585c@gutov.dev> (message from Dmitry Gutov on Tue, 11 Apr 2023 00:02:03 +0300) 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:259621 Archived-At: > Date: Tue, 11 Apr 2023 00:02:03 +0300 > From: Dmitry Gutov > > module M > module N > module C > class D > def C.foo > _ > end > end > end > end > end > > (ruby-add-log-current-method) currently returns "M::C.foo" > > While it should return "M::N::C.foo". Patch attached. > > This discovery stems from Mattias EngdegÄrd's report (in private) about > an ignored return value from `nreverse`. > > Is this good for emacs-29? I guess so. But I wonder: this code was there since ruby-mode.el was added to Emacs in 2008, so are you saying that (cdr ml) can never be nil at this place, or if it is, it's okay to leave ml at the nil value? IOW, the return value of nreverse has been ignored, but what about the nreverse call before that: > --- a/lisp/progmodes/ruby-mode.el > +++ b/lisp/progmodes/ruby-mode.el > @@ -1911,7 +1911,7 @@ ruby-add-log-current-method > (while ml > (if (string-equal (car ml) (car mn)) > (setq mlist (nreverse (cdr ml)) ml nil)) > - (or (setq ml (cdr ml)) (nreverse mlist)))) > + (setq ml (cdr ml)))) > (if mlist > (setcdr (last mlist) (butlast mn)) > (setq mlist (butlast mn)))) Isn't the second nreverse there to undo the first? I guess I'm asking for slightly more detailed rationale for the change you are proposing, to include the analysis of the code involved and where that code is mistaken. For example, why not say (setq mlist (nreverse mlist)) or (setq ml (nreverse mlist)) instead of just removing the 2nd nreverse call? Thanks.