Define the initialize_copy and respond_to_missing? methods as private

It is preferable for them to be private even when defined via `mrb_define_method()`.
This mimics CRuby's behavior.

ref: https://github.com/ruby/ruby/blob/v4.0.0/vm_method.c#L1329-L1336
This commit is contained in:
dearblue
2026-01-18 20:56:51 +09:00
parent 3a1b771cc6
commit 8a8e2ddad9
+3 -1
View File
@@ -1027,7 +1027,9 @@ mrb_define_method_raw(mrb_state *mrb, struct RClass *c, mrb_sym mid, mrb_method_
}
int flags = MT_KEY_FLG(m.flags);
if (mid == MRB_SYM(initialize)) {
if (mid == MRB_SYM(initialize) ||
mid == MRB_SYM(initialize_copy) ||
mid == MRB_SYM_Q(respond_to_missing)) {
MRB_SET_VISIBILITY_FLAGS(flags, MT_PRIVATE);
}
else if ((flags & MT_VMASK) == MT_VDEFAULT) {