From a79c59472df38297c246b27713c277f2edaefa7a Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Wed, 5 Jan 2022 16:12:31 -0800 Subject: Allow include before calling Module#initialize This is to allow Module subclasses that include modules before calling super in the subclass's initialize. Remove rb_module_check_initializable from Module#initialize. Module#initialize only calls module_exec if a block is passed, it doesn't have other issues that would cause problems if called multiple times or with an already initialized module. Move initialization of super to Module#allocate, though I'm not sure it is required there. However, it's needed to be removed from Module#initialize for this to work. Fixes [Bug #18292] --- class.c | 1 + 1 file changed, 1 insertion(+) (limited to 'class.c') diff --git a/class.c b/class.c index 1281a243ab..5ece9e34e8 100644 --- a/class.c +++ b/class.c @@ -912,6 +912,7 @@ rb_module_s_alloc(VALUE klass) VALUE mod = class_alloc(T_MODULE, klass); RCLASS_M_TBL_INIT(mod); FL_SET(mod, RMODULE_ALLOCATED_BUT_NOT_INITIALIZED); + RB_OBJ_WRITE(mod, &RCLASS(mod)->super, 0); return mod; } -- cgit v1.2.1