summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2013-04-02 10:33:54 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2013-04-02 10:33:54 +0900
commit6bd49a3d95c836e82382f333a600a368bf0638fc (patch)
tree8d7c6f7691562db49a07aa86529727d07219cc3a /src
parent013be527e65fa0b93db49b6d89550700b4fe80cc (diff)
downloadmruby-6bd49a3d95c836e82382f333a600a368bf0638fc.tar.gz
mruby-6bd49a3d95c836e82382f333a600a368bf0638fc.zip
Module#constants should include constants defined in superclass; close #1126
Diffstat (limited to 'src')
-rw-r--r--src/variable.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/variable.c b/src/variable.c
index c3b77d75c..a9570db02 100644
--- a/src/variable.c
+++ b/src/variable.c
@@ -946,10 +946,15 @@ mrb_value
mrb_mod_constants(mrb_state *mrb, mrb_value mod)
{
mrb_value ary;
+ struct RClass *c = mrb_class_ptr(mod);
ary = mrb_ary_new(mrb);
- if (obj_iv_p(mod) && mrb_obj_ptr(mod)->iv) {
- iv_foreach(mrb, mrb_obj_ptr(mod)->iv, const_i, &ary);
+ while (c) {
+ if (c->iv) {
+ iv_foreach(mrb, c->iv, const_i, &ary);
+ }
+ c = c->super;
+ if (c == mrb->object_class) break;
}
return ary;
}