diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-13 08:07:36 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-13 08:07:36 +0000 |
commit | f70e60783e2b83c5749f9461d156d3bd9a5c221a (patch) | |
tree | e7770d99121cb5f039bf79b687f92cde1b303f89 | |
parent | 92958d0a46534f5bb02854432eeed82dd77dfe02 (diff) |
merges r24012 from trunk into ruby_1_9_1.
--
* vm_insnhelper.c (vm_search_superclass): checks for implicit
argument passing before method search. [ruby-core:24244]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@24077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | test/ruby/test_super.rb | 8 | ||||
-rw-r--r-- | version.h | 2 | ||||
-rw-r--r-- | vm_insnhelper.c | 24 |
4 files changed, 31 insertions, 8 deletions
@@ -1,3 +1,8 @@ +Fri Jul 10 10:25:19 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * vm_insnhelper.c (vm_search_superclass): checks for implici + argument passing before method search. [ruby-core:24244] + Thu Jul 9 21:56:59 2009 NARUSE, Yui <naruse@ruby-lang.org> * marshal.c (r_object0): replace \u by u when the regexp is diff --git a/test/ruby/test_super.rb b/test/ruby/test_super.rb index 5e93074e2d..8de1e2fa7e 100644 --- a/test/ruby/test_super.rb +++ b/test/ruby/test_super.rb @@ -130,5 +130,13 @@ class TestSuper < Test::Unit::TestCase a = A.new a.uu(12) assert_equal("A#tt", a.tt(12), "[ruby-core:3856]") + e = assert_raise(RuntimeError, "[ruby-core:24244]") { + lambda { + Class.new do + define_method(:a) {super}.call + end + }.call + } + assert_match(/implicit argument passing of super from method defined by define_method/, e.message) end end @@ -4,7 +4,7 @@ #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 -#define RUBY_PATCHLEVEL 226 +#define RUBY_PATCHLEVEL 227 #define RUBY_RELEASE_YEAR 2009 #define RUBY_RELEASE_MONTH 7 #define RUBY_RELEASE_DAY 12 diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 6132bd0fa0..8a1306ab9e 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -360,10 +360,18 @@ vm_call_cfunc(rb_thread_t *th, rb_control_frame_t *reg_cfp, int num, ID id, ID oid, VALUE recv, VALUE klass, VALUE flag, const NODE *mn, const rb_block_t *blockptr) { - VALUE val; + VALUE val = 0; + int state = 0; EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, recv, id, klass); - { + TH_PUSH_TAG(th); + if (th->event_flags & RUBY_EVENT_C_RETURN) { + state = TH_EXEC_TAG(); + } + else { + _th->tag = _tag.prev; + } + if (state == 0) { rb_control_frame_t *cfp = vm_push_frame(th, 0, VM_FRAME_MAGIC_CFUNC, recv, (VALUE) blockptr, 0, reg_cfp->sp, 0, 1); @@ -381,7 +389,9 @@ vm_call_cfunc(rb_thread_t *th, rb_control_frame_t *reg_cfp, vm_pop_frame(th); } + TH_POP_TAG(); EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, recv, id, klass); + if (state) TH_JUMP_TAG(th, state); return val; } @@ -1228,6 +1238,11 @@ vm_search_superclass(rb_control_frame_t *reg_cfp, rb_iseq_t *ip, /* defined by Module#define_method() */ rb_control_frame_t *lcfp = GET_CFP(); + if (!sigval) { + /* zsuper */ + rb_raise(rb_eRuntimeError, "implicit argument passing of super from method defined by define_method() is not supported. Specify all arguments explicitly."); + } + while (lcfp->iseq != ip) { VALUE *tdfp = GET_PREV_DFP(lcfp->dfp); while (1) { @@ -1240,11 +1255,6 @@ vm_search_superclass(rb_control_frame_t *reg_cfp, rb_iseq_t *ip, id = lcfp->method_id; klass = vm_search_normal_superclass(lcfp->method_class, recv); - - if (sigval == Qfalse) { - /* zsuper */ - rb_raise(rb_eRuntimeError, "implicit argument passing of super from method defined by define_method() is not supported. Specify all arguments explicitly."); - } } else { klass = vm_search_normal_superclass(ip->klass, recv); |