mruby-metaprog (mrb_mod_s_constants): call Module#constants if possible

When the optional argument is given or the receiver is not `Module`.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2025-04-11 22:49:30 +09:00
parent 82522a2e71
commit cda551ce25
+3
View File
@@ -643,6 +643,9 @@ mrb_mod_remove_method(mrb_state *mrb, mrb_value mod)
static mrb_value
mrb_mod_s_constants(mrb_state *mrb, mrb_value mod)
{
if (mrb_get_argc(mrb) > 0 || mrb_class_ptr(mod) != mrb->module_class) {
return mrb_mod_constants(mrb, mod);
}
mrb_raise(mrb, E_NOTIMP_ERROR, "Module.constants not implemented");
return mrb_nil_value(); /* not reached */
}