From e2137aa24b8328f44c26da2fc20fcc744b9f8d8b Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 9 Sep 2016 01:10:01 +0000 Subject: variable.c: fix deprecated constant message * variable.c (rb_const_search): warn with the actual class/module name which defines the deprecated constant. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 ++++- test/ruby/test_module.rb | 1 + variable.c | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a974f00695..284eb61051 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,7 @@ -Fri Sep 9 10:07:40 2016 Nobuyoshi Nakada +Fri Sep 9 10:10:00 2016 Nobuyoshi Nakada + + * variable.c (rb_const_search): warn with the actual class/module + name which defines the deprecated constant. * variable.c (rb_const_search): raise with the actual class/module name which defines the private constant. diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index 43bd3f72b6..e9529273eb 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -1420,6 +1420,7 @@ class TestModule < Test::Unit::TestCase c.const_set(:FOO, "foo") c.deprecate_constant(:FOO) assert_warn(/deprecated/) {c::FOO} + assert_warn(/#{c}::FOO is deprecated/) {Class.new(c)::FOO} bug12382 = '[ruby-core:75505] [Bug #12382]' assert_warn(/deprecated/, bug12382) {c.class_eval "FOO"} end diff --git a/variable.c b/variable.c index 277edb83b4..2465212ab9 100644 --- a/variable.c +++ b/variable.c @@ -2263,7 +2263,7 @@ rb_const_search(VALUE klass, ID id, int exclude, int recurse, int visibility) rb_name_err_raise("private constant %2$s::%1$s referenced", tmp, ID2SYM(id)); } - rb_const_warn_if_deprecated(ce, klass, id); + rb_const_warn_if_deprecated(ce, tmp, id); value = ce->value; if (value == Qundef) { if (am == tmp) break; -- cgit v1.2.3