diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-09-09 01:07:41 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-09-09 01:07:41 +0000 |
commit | a213d41c11dbc227f02a3bc15bca8377c3e34be9 (patch) | |
tree | 15778eae93cee1e35b6a5f6b358e80299aefeb6b | |
parent | 51b6ab76e83173ca57eded7ce14094e125ee0b73 (diff) | |
download | ruby-a213d41c11dbc227f02a3bc15bca8377c3e34be9.tar.gz |
variable.c: fix private constant message
* 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/trunk@56117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | test/ruby/test_module.rb | 3 | ||||
-rw-r--r-- | variable.c | 2 |
3 files changed, 9 insertions, 1 deletions
@@ -1,3 +1,8 @@ +Fri Sep 9 10:07:40 2016 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * variable.c (rb_const_search): raise with the actual class/module + name which defines the private constant. + Thu Sep 8 17:47:18 2016 Kazuki Tsujimoto <kazuki@callcc.net> * array.c (flatten): use rb_obj_class instead of rb_class_of diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index 0f9351c57d..43bd3f72b6 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -1360,6 +1360,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 0966685690..277edb83b4 100644 --- a/variable.c +++ b/variable.c @@ -2261,7 +2261,7 @@ rb_const_search(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_err_raise("private constant %2$s::%1$s referenced", - klass, ID2SYM(id)); + tmp, ID2SYM(id)); } rb_const_warn_if_deprecated(ce, klass, id); value = ce->value; |