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

ruby-changes:39661

From: nobu <ko1@a...>
Date: Thu, 3 Sep 2015 10:08:18 +0900 (JST)
Subject: [ruby-changes:39661] nobu:r51742 (trunk): vm_eval.c: refine messages

nobu	2015-09-03 10:07:52 +0900 (Thu, 03 Sep 2015)

  New Revision: 51742

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

  Log:
    vm_eval.c: refine messages
    
    * vm_eval.c (raise_method_missing): refine error messages when a
      symbol is not given.  [Fix GH-1013]

  Modified files:
    trunk/ChangeLog
    trunk/vm_eval.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51741)
+++ ChangeLog	(revision 51742)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Sep  3 10:07:49 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* vm_eval.c (raise_method_missing): refine error messages when a
+	  symbol is not given.  [Fix GH-1013]
+
 Wed Sep  2 18:49:55 2015  SHIBATA Hiroshi  <hsbt@r...>
 
 	* ext/psych/*: merge psych master(8737e5b). It contains following fixes.
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 51741)
+++ vm_eval.c	(revision 51742)
@@ -693,8 +693,13 @@ raise_method_missing(rb_thread_t *th, in https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L693
     VALUE exc = rb_eNoMethodError;
     const char *format = 0;
 
-    if (argc == 0 || !SYMBOL_P(argv[0])) {
-	rb_raise(rb_eArgError, "no id given");
+    if (UNLIKELY(argc == 0)) {
+	rb_raise(rb_eArgError, "no method names given");
+    }
+    else if (UNLIKELY(!SYMBOL_P(argv[0]))) {
+	const VALUE e = rb_eArgError; /* TODO: TypeError? */
+	rb_raise(e, "method name must be a Symbol but %"PRIsVALUE" is given",
+		 rb_obj_class(argv[0]));
     }
 
     stack_check();

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

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