diff --git a/ChangeLog b/ChangeLog index abf3ec3c30..648ef8c89f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu Jul 16 17:41:28 2009 Koichi Sasada + + * vm_method.c (rb_alias): fix a case which try non-existing method alias. + + * test/ruby/test_alias.rb: add a test. + Thu Jul 16 15:52:25 2009 Nobuyoshi Nakada * bignum.c (rb_big_new, rb_bigzero_p), range.c (rb_range_values): diff --git a/test/ruby/test_alias.rb b/test/ruby/test_alias.rb index 10fd8f1112..f66c4a6340 100644 --- a/test/ruby/test_alias.rb +++ b/test/ruby/test_alias.rb @@ -61,4 +61,12 @@ class TestAlias < Test::Unit::TestCase }.call assert_raise(SecurityError) { d.mm } end + + def test_nonexistmethod + assert_raise(NameError){ + Class.new{ + alias_method :foobarxyzzy, :barbaz + } + } + end end diff --git a/vm_method.c b/vm_method.c index b85351a671..4b747e9d52 100644 --- a/vm_method.c +++ b/vm_method.c @@ -814,10 +814,9 @@ rb_alias(VALUE klass, ID name, ID def) if (!orig_me || orig_me->type == VM_METHOD_TYPE_UNDEF) { if (TYPE(klass) == T_MODULE) { orig_me = search_method(rb_cObject, def); - - if (!orig_me || !orig_me->type == VM_METHOD_TYPE_UNDEF) { - rb_print_undef(klass, def, 0); - } + } + if (!orig_me || !orig_me->type == VM_METHOD_TYPE_UNDEF) { + rb_print_undef(klass, def, 0); } } if (FL_TEST(klass, FL_SINGLETON)) {