From: "nobu (Nobuyoshi Nakada)" <noreply@ruby-lang.org>
To: ruby-core@ruby-lang.org
Subject: [ruby-core:108131] [Ruby master Bug#18670] MatchData#[start, length] pads nil values when negative start is given
Date: Thu, 31 Mar 2022 06:35:44 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-97106.20220331063543.13423@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-18670.20220330163004.13423@ruby-lang.org
Issue #18670 has been updated by nobu (Nobuyoshi Nakada).
Backport changed from 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN to 2.6: UNKNOWN, 2.7: REQUIRED, 3.0: REQUIRED, 3.1: REQUIRED
It is since 2.4.0.
----------------------------------------
Bug #18670: MatchData#[start, length] pads nil values when negative start is given
https://bugs.ruby-lang.org/issues/18670#change-97106
* Author: bjfish (Brandon Fish)
* Status: Open
* Priority: Normal
* ruby -v: 3.0.3
* Backport: 2.6: UNKNOWN, 2.7: REQUIRED, 3.0: REQUIRED, 3.1: REQUIRED
----------------------------------------
Example
``` ruby
irb(main):001:0> /(.)(.)(\d+)(\d)/.match("THX1138.")[-1, 10]
=> ["8", nil, nil, nil, nil, nil, nil, nil, nil, nil]
```
I would expect this to be consistent with String or Array for example:
``` ruby
irb(main):002:0> "hello"[-1, 10]
=> "o"
irb(main):003:0> [1,2,3][-1,10]
=> [3]
```
--
https://bugs.ruby-lang.org/
next prev parent reply other threads:[~2022-03-31 6:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-30 16:30 [ruby-core:108122] [Ruby master Bug#18670] MatchData#[start, length] pads nil values when negative start is given bjfish (Brandon Fish)
2022-03-31 6:35 ` nobu (Nobuyoshi Nakada) [this message]
2022-03-31 6:46 ` [ruby-core:108132] " nobu (Nobuyoshi Nakada)
2022-09-04 7:25 ` [ruby-core:109836] " nagachika (Tomoyuki Chikanaga)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-97106.20220331063543.13423@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).