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

ruby-changes:13776

From: nobu <ko1@a...>
Date: Fri, 30 Oct 2009 16:57:37 +0900 (JST)
Subject: [ruby-changes:13776] Ruby:r25573 (trunk): * vm_eval.c (vm_call0, vm_call_super, rb_f_send, rb_f_public_send):

nobu	2009-10-30 16:57:21 +0900 (Fri, 30 Oct 2009)

  New Revision: 25573

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

  Log:
    * vm_eval.c (vm_call0, vm_call_super, rb_f_send, rb_f_public_send):
      fixed call_type.  [ruby-dev:39581]

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_object.rb
    trunk/vm_eval.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 25572)
+++ ChangeLog	(revision 25573)
@@ -1,5 +1,8 @@
-Fri Oct 30 16:42:03 2009  Nobuyoshi Nakada  <nobu@r...>
+Fri Oct 30 16:57:19 2009  Nobuyoshi Nakada  <nobu@r...>
 
+	* vm_eval.c (vm_call0, vm_call_super, rb_f_send, rb_f_public_send):
+	  fixed call_type.  [ruby-dev:39581]
+
 	* vm_eval.c (rb_search_method_emtry, rb_method_call_status): spli
 	  from rb_call0().
 
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 25572)
+++ vm_eval.c	(revision 25573)
@@ -21,7 +21,6 @@
 static VALUE vm_exec(rb_thread_t *th);
 static void vm_set_eval_stack(rb_thread_t * th, VALUE iseqval, const NODE *cref);
 static int vm_collect_local_variables_in_heap(rb_thread_t *th, VALUE *dfp, VALUE ary);
-static VALUE send_internal(int argc, const VALUE *argv, VALUE recv, int scope);
 
 typedef enum call_type {
     CALL_PUBLIC,
@@ -29,6 +28,8 @@
     CALL_VCALL,
 } call_type;
 
+static VALUE send_internal(int argc, const VALUE *argv, VALUE recv, call_type scope);
+
 static inline VALUE
 vm_call0(rb_thread_t* th, VALUE recv, VALUE id, int argc, const VALUE *argv,
 	 const rb_method_entry_t *me)
@@ -104,7 +105,7 @@
       case VM_METHOD_TYPE_ZSUPER: {
 	klass = RCLASS_SUPER(klass);
 	if (!klass || !(me = rb_method_entry(klass, id))) {
-	    return method_missing(recv, id, argc, argv, 0);
+	    return method_missing(recv, id, argc, argv, NOEX_SUPER);
 	}
 	RUBY_VM_CHECK_INTS();
 	if (!(def = me->def)) return Qnil;
@@ -121,7 +122,7 @@
       case VM_METHOD_TYPE_OPTIMIZED: {
 	switch (def->body.optimize_type) {
 	  case OPTIMIZED_METHOD_TYPE_SEND:
-	    val = send_internal(argc, argv, recv, NOEX_NOSUPER | NOEX_PRIVATE);
+	    val = send_internal(argc, argv, recv, CALL_FCALL);
 	    break;
 	  case OPTIMIZED_METHOD_TYPE_CALL: {
 	    rb_proc_t *proc;
@@ -175,7 +176,7 @@
 
     me = rb_method_entry(klass, id);
     if (!me) {
-	return method_missing(recv, id, argc, argv, 0);
+	return method_missing(recv, id, argc, argv, NOEX_SUPER);
     }
 
     return vm_call0(th, recv, id, argc, argv, me);
@@ -573,7 +574,7 @@
 }
 
 static VALUE
-send_internal(int argc, const VALUE *argv, VALUE recv, int scope)
+send_internal(int argc, const VALUE *argv, VALUE recv, call_type scope)
 {
     VALUE vid;
     VALUE self = RUBY_VM_PREVIOUS_CONTROL_FRAME(GET_THREAD()->cfp)->self;
@@ -610,7 +611,7 @@
 VALUE
 rb_f_send(int argc, VALUE *argv, VALUE recv)
 {
-    return send_internal(argc, argv, recv, NOEX_NOSUPER | NOEX_PRIVATE);
+    return send_internal(argc, argv, recv, CALL_FCALL);
 }
 
 /*
@@ -627,7 +628,7 @@
 VALUE
 rb_f_public_send(int argc, VALUE *argv, VALUE recv)
 {
-    return send_internal(argc, argv, recv, NOEX_PUBLIC);
+    return send_internal(argc, argv, recv, CALL_PUBLIC);
 }
 
 /* yield */
Index: test/ruby/test_object.rb
===================================================================
--- test/ruby/test_object.rb	(revision 25572)
+++ test/ruby/test_object.rb	(revision 25573)
@@ -377,6 +377,31 @@
     assert_raise(ArgumentError) { 1.send }
   end
 
+  def test_no_superclass_method
+    bug2312 = '[ruby-dev:39581]'
+
+    o = Object.new
+    e = assert_raise(NoMethodError) {
+      o.method(:__send__).call(:never_defined_test_no_superclass_method)
+    }
+    m1 = e.message
+    assert_no_match(/no superclass method/, m1, bug2312)
+    e = assert_raise(NoMethodError) {
+      o.method(:__send__).call(:never_defined_test_no_superclass_method)
+    }
+    assert_equal(m1, e.message, bug2312)
+    e = assert_raise(NoMethodError) {
+      o.never_defined_test_no_superclass_method
+    }
+    assert_equal(m1, e.message, bug2312)
+  end
+
+  def test_superclass_method
+    bug2312 = '[ruby-dev:39581]'
+    assert_in_out_err(["-e", "module Enumerable;undef min;end; (1..2).min{}"],
+                      [], [], /no superclass method/, bug2312)
+  end
+
   def test_specific_eval_with_wrong_arguments
     assert_raise(ArgumentError) do
       1.instance_eval("foo") { foo }

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

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