summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2014-10-20 11:11:26 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2014-10-20 11:11:26 +0900
commit69ba4f0ed5e7ce179a01316dea753042dfcdfd77 (patch)
tree59a392075f89292b8a2d370953a6f662da4cda50
parentcee3dc58d6993c80256b1d2aba5abf70de76499a (diff)
downloadmruby-69ba4f0ed5e7ce179a01316dea753042dfcdfd77.tar.gz
mruby-69ba4f0ed5e7ce179a01316dea753042dfcdfd77.zip
instance_methods etc should not include undef'ed method names; based on a patch from @cremno; fix #2613
-rw-r--r--src/kernel.c2
-rw-r--r--test/t/module.rb1
2 files changed, 2 insertions, 1 deletions
diff --git a/src/kernel.c b/src/kernel.c
index 2f52c7bdf..22fe40218 100644
--- a/src/kernel.c
+++ b/src/kernel.c
@@ -614,7 +614,7 @@ method_entry_loop(mrb_state *mrb, struct RClass* klass, khash_t(st)* set)
khash_t(mt) *h = klass->mt;
if (!h) return;
for (i=0;i<kh_end(h);i++) {
- if (kh_exist(h, i)) {
+ if (kh_exist(h, i) && kh_value(h, i)) {
kh_put(st, mrb, set, kh_key(h, i));
}
}
diff --git a/test/t/module.rb b/test/t/module.rb
index 8503cb9fc..9852328ce 100644
--- a/test/t/module.rb
+++ b/test/t/module.rb
@@ -469,6 +469,7 @@ assert('Module#undef_method', '15.2.2.4.42') do
assert_true Test4UndefMethod::Parent.new.respond_to?(:hello)
assert_false Test4UndefMethod::Child.new.respond_to?(:hello)
assert_false Test4UndefMethod::GrandChild.new.respond_to?(:hello)
+ assert_false Test4UndefMethod::Child.instance_methods(false).include? :hello
end
# Not ISO specified