From: nobu@ruby-lang.org
To: ruby-dev@ruby-lang.org
Subject: [ruby-dev:50295] [Ruby trunk Bug#14006] 2.5.0preview1でWarning.warnを再定義するとSystemStackErrorが発生する
Date: Thu, 12 Oct 2017 08:22:11 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-67185.20171012082210.3c69cb9283c1f4d8@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-14006.20171012021319@ruby-lang.org
Issue #14006 has been updated by nobu (Nobuyoshi Nakada).
再定義は `Warning.warn` にするという想定だったんですが、 `Warning#warn` の再定義はどうしましょうかねぇ。
----------------------------------------
Bug #14006: 2.5.0preview1でWarning.warnを再定義するとSystemStackErrorが発生する
https://bugs.ruby-lang.org/issues/14006#change-67185
* Author: y-yagi (Yuji Yaginuma)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.5.0preview1 (2017-10-10 trunk 60153) [x86_64-linux]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
下記スクリプトを2.5.0.preview1で実行するとSystemStackErrorが発生します。 なお、下記スクリプトはRuby 2.4.1p111ではエラーが発生せず正常に動作します。
~~~ ruby
# warning_test.rb
module Warning
def warn(message)
return if message.match?("warning: possibly useless use of a variable in void context")
super
end
end
@a
~~~
バックトレースは下記の通りです。
~~~
ruby -v warning_test.rb
ruby 2.5.0preview1 (2017-10-10 trunk 60153) [x86_64-linux]
warning_test.rb:9: warning: possibly useless use of a variable in void context
warning_test.rb:2: warning: method redefined; discarding old warn
Traceback (most recent call last):
7580: from warning_test.rb:9:in `<main>'
7579: from warning_test.rb:5:in `warn'
7578: from warning_test.rb:5:in `warn'
7577: from warning_test.rb:5:in `warn'
7576: from warning_test.rb:5:in `warn'
7575: from warning_test.rb:5:in `warn'
7574: from warning_test.rb:5:in `warn'
7573: from warning_test.rb:5:in `warn'
... 7568 levels...
4: from warning_test.rb:5:in `warn'
3: from warning_test.rb:5:in `warn'
2: from warning_test.rb:5:in `warn'
1: from warning_test.rb:5:in `warn'
warning_test.rb:5:in `warn': stack level too deep (SystemStackError)
~~~
なお、再定義の方法を、
~~~ ruby
def Warning.warn(message)
...
end
~~~
のように変更すると、エラーが発生せず正常に動作します。
これは意図的な挙動でしょうか?
--
https://bugs.ruby-lang.org/
prev parent reply other threads:[~2017-10-12 8:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <redmine.issue-14006.20171012021319@ruby-lang.org>
2017-10-12 2:13 ` [ruby-dev:50293] [Ruby trunk Bug#14006] 2.5.0preview1でWarning.warnを再定義するとSystemStackErrorが発生する yuuji.yaginuma
2017-10-12 5:01 ` [ruby-dev:50294] " shevegen
2017-10-12 8:22 ` nobu [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-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-67185.20171012082210.3c69cb9283c1f4d8@ruby-lang.org \
--to=ruby-dev@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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).