From a6bc3808218eb1c7a4f4f37a3d8d63f0833170a3 Mon Sep 17 00:00:00 2001 From: usa Date: Fri, 30 Sep 2016 16:05:44 +0000 Subject: merge revision(s) 56117: [Backport #12742] * variable.c (rb_const_search): raise with the actual class/module name which defines the private constant. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@56309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ test/ruby/test_module.rb | 3 +++ variable.c | 2 +- version.h | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 044acfb822..10d4e7d676 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Oct 1 01:02:22 2016 Nobuyoshi Nakada + + * variable.c (rb_const_search): raise with the actual class/module + name which defines the private constant. + Sat Oct 1 00:57:54 2016 NARUSE, Yui * vm_dump.c (backtrace): use rip in the saved context for the case diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index 3aecccabed..468932757a 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -1306,6 +1306,9 @@ class TestModule < Test::Unit::TestCase c.const_set(:FOO, "foo") $VERBOSE = verbose assert_raise(NameError) { c::FOO } + assert_raise_with_message(NameError, /#{c}::FOO/) do + Class.new(c)::FOO + end end def test_private_constant2 diff --git a/variable.c b/variable.c index 1b875e543c..691af04d3c 100644 --- a/variable.c +++ b/variable.c @@ -1852,7 +1852,7 @@ rb_const_get_0(VALUE klass, ID id, int exclude, int recurse, int visibility) while ((ce = rb_const_lookup(tmp, id))) { if (visibility && RB_CONST_PRIVATE_P(ce)) { rb_name_error(id, "private constant %"PRIsVALUE"::%"PRIsVALUE" referenced", - rb_class_name(klass), QUOTE_ID(id)); + rb_class_name(tmp), QUOTE_ID(id)); } value = ce->value; if (value == Qundef) { diff --git a/version.h b/version.h index 56843a1a9f..ef29331914 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.2.6" #define RUBY_RELEASE_DATE "2016-10-01" -#define RUBY_PATCHLEVEL 378 +#define RUBY_PATCHLEVEL 379 #define RUBY_RELEASE_YEAR 2016 #define RUBY_RELEASE_MONTH 10 -- cgit v1.2.3