summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--test/ruby/test_alias.rb15
-rw-r--r--vm_method.c2
3 files changed, 21 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 8a230d4e4b..fcf5b0e7b2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sun Mar 23 11:03:27 2014 Kohei Suzuki <eagletmt@gmail.com>
+
+ * vm_method.c (rb_method_entry_get_without_cache): me->klass is 0
+ for a method aliased in a module. [ruby-core:61636] [Bug #9663]
+
Sun Mar 23 08:12:27 2014 Eric Wong <e@80x24.org>
* st.c (hash_pos): use bitwise AND to avoid slow modulo op
diff --git a/test/ruby/test_alias.rb b/test/ruby/test_alias.rb
index 4e1db2e13f..dec61f6d63 100644
--- a/test/ruby/test_alias.rb
+++ b/test/ruby/test_alias.rb
@@ -179,4 +179,19 @@ class TestAlias < Test::Unit::TestCase
assert_equal("ABC", c.new.foo, bug9475)
end
end
+
+ def test_alias_in_module
+ bug9663 = '[ruby-core:61635] [Bug #9663]'
+
+ assert_separately(['-', bug9663], <<-'end;')
+ bug = ARGV[0]
+
+ m = Module.new do
+ alias orig_to_s to_s
+ end
+
+ o = Object.new.extend(m)
+ assert_equal(o.to_s, o.orig_to_s, bug)
+ end;
+ end
end
diff --git a/vm_method.c b/vm_method.c
index 2279190d8a..06ff053339 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -578,7 +578,7 @@ rb_method_entry_get_without_cache(VALUE klass, ID id,
VALUE defined_class;
rb_method_entry_t *me = search_method(klass, id, &defined_class);
- if (me) {
+ if (me && !me->klass) {
switch (BUILTIN_TYPE(me->klass)) {
case T_CLASS:
if (RBASIC(klass)->flags & FL_SINGLETON) break;