diff --git a/ChangeLog b/ChangeLog index 22127587ab..c5d0dbb1df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,7 @@ -Fri Oct 30 16:42:03 2009 Nobuyoshi Nakada +Fri Oct 30 16:57:19 2009 Nobuyoshi Nakada + + * 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(). diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb index 3980b5d41c..e90ca3b6d9 100644 --- a/test/ruby/test_object.rb +++ b/test/ruby/test_object.rb @@ -377,6 +377,31 @@ class TestObject < Test::Unit::TestCase 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 } diff --git a/vm_eval.c b/vm_eval.c index 7a3d48f6b9..0f93a96d27 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -21,7 +21,6 @@ static NODE *vm_cref_push(rb_thread_t *th, VALUE klass, int noex); 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 @@ typedef enum call_type { 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 @@ vm_call0(rb_thread_t* th, VALUE recv, VALUE id, int argc, const VALUE *argv, 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 @@ vm_call0(rb_thread_t* th, VALUE recv, VALUE id, int argc, const VALUE *argv, 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 @@ vm_call_super(rb_thread_t *th, int argc, const VALUE *argv) 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 @@ rb_funcall3(VALUE recv, ID mid, int argc, const VALUE *argv) } 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 @@ send_internal(int argc, const VALUE *argv, VALUE recv, int scope) 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 @@ rb_f_send(int argc, VALUE *argv, VALUE recv) 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 */