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

ruby-changes:15543

From: mame <ko1@a...>
Date: Thu, 22 Apr 2010 23:15:45 +0900 (JST)
Subject: [ruby-changes:15543] Ruby:r27446 (trunk): * proc.c (mnew): fix wrong error message when Kernel#public_method

mame	2010-04-22 23:15:29 +0900 (Thu, 22 Apr 2010)

  New Revision: 27446

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=27446

  Log:
    * proc.c (mnew): fix wrong error message when Kernel#public_method
      receives name of private method.  [Bug #2425]

  Modified files:
    trunk/ChangeLog
    trunk/proc.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 27445)
+++ ChangeLog	(revision 27446)
@@ -1,3 +1,8 @@
+Thu Apr 22 23:10:59 2010  Yusuke Endoh  <mame@t...>
+
+	* proc.c (mnew): fix wrong error message when Kernel#public_method
+	  receives name of private method.  [Bug #2425]
+
 Thu Apr 22 22:56:42 2010  Yusuke Endoh  <mame@t...>
 
 	* bootstraptest/test_thread.rb: fix test.  [Bug #2342]
Index: proc.c
===================================================================
--- proc.c	(revision 27445)
+++ proc.c	(revision 27446)
@@ -925,7 +925,16 @@
     if (flag == NOEX_UNDEF) {
 	flag = me->flag;
 	if (scope && (flag & NOEX_MASK) != NOEX_PUBLIC) {
-	    rb_print_undef(rclass, def->original_id, (int)(flag & NOEX_MASK));
+	    const char *v = "";
+	    switch (flag & NOEX_MASK) {
+		case NOEX_PRIVATE: v = "private"; break;
+		case NOEX_PROTECTED: v = "protected"; break;
+	    }
+	    rb_name_error(id, "method `%s' for %s `%s' is %s",
+			  rb_id2name(id),
+			  (TYPE(klass) == T_MODULE) ? "module" : "class",
+			  rb_class2name(klass),
+			  v);
 	}
     }
     if (def && def->type == VM_METHOD_TYPE_ZSUPER) {

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

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