[前][次][番号順一覧][スレッド一覧]

ruby-changes:44044

From: nobu <ko1@a...>
Date: Fri, 9 Sep 2016 10:08:04 +0900 (JST)
Subject: [ruby-changes:44044] nobu:r56117 (trunk): variable.c: fix private constant message

nobu	2016-09-09 10:07:41 +0900 (Fri, 09 Sep 2016)

  New Revision: 56117

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56117

  Log:
    variable.c: fix private constant message
    
    * variable.c (rb_const_search): raise with the actual class/module
      name which defines the private constant.

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_module.rb
    trunk/variable.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 56116)
+++ ChangeLog	(revision 56117)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Sep  9 10:07:40 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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@c...>
 
 	* array.c (flatten): use rb_obj_class instead of rb_class_of
Index: test/ruby/test_module.rb
===================================================================
--- test/ruby/test_module.rb	(revision 56116)
+++ test/ruby/test_module.rb	(revision 56117)
@@ -1360,6 +1360,9 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L1360
     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
Index: variable.c
===================================================================
--- variable.c	(revision 56116)
+++ variable.c	(revision 56117)
@@ -2261,7 +2261,7 @@ rb_const_search(VALUE klass, ID id, int https://github.com/ruby/ruby/blob/trunk/variable.c#L2261
 	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;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]