From: merch-redmine@jeremyevans.net
To: ruby-dev@ruby-lang.org
Subject: [ruby-dev:51047] [Ruby master Bug#17571] prependしたArray#[] が反映されない
Date: Fri, 09 Apr 2021 17:23:40 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-91439.20210409172340.20841@ruby-lang.org> (raw)
In-Reply-To: <redmine.issue-17571.20210122234903.20841@ruby-lang.org>
Issue #17571 has been updated by jeremyevans0 (Jeremy Evans).
Status changed from Open to Closed
I tested with the master branch and Ruby 3.0.1, and this problem appears fixed.
----------------------------------------
Bug #17571: prependしたArray#[] が反映されない
https://bugs.ruby-lang.org/issues/17571#change-91439
* Author: freedom (free dom)
* Status: Closed
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
Arrayクラスにprependを使い`[]`メソッドを差し込んでもprependした`[]`を呼び出しません
また、Hashを継承したクラス(以下HashB)のインスタンスでHash#[]を既に呼び出している場合
prependして差し込んだ`[]`を通らずにHash#[]が呼び出されているようです
HashBのインスタンス呼び出しがprependより後の場合は期待通り動きました
再現コード(Array)
``` ruby
module TestMod
def [](*)
p :called
super
end
end
Array.prepend TestMod
[][1] # => 何も出力されない
```
再現コード(Hash)
``` ruby
module TestMod
def [](*)
p :called
super
end
end
class HashB < Hash;end
HashB.new[1]
Hash.prepend TestMod
{}[1] # => 何も出力されない
```
よろしくおねがいします
--
https://bugs.ruby-lang.org/
prev parent reply other threads:[~2021-04-09 17:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-22 23:49 [ruby-dev:50993] " under_free_fall
2021-04-09 17:23 ` merch-redmine [this message]
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-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-91439.20210409172340.20841@ruby-lang.org \
--to=merch-redmine@jeremyevans.net \
--cc=ruby-dev@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 NNTP newsgroup(s).