summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--class.c1
-rw-r--r--object.c1
-rw-r--r--test/ruby/test_module.rb10
3 files changed, 11 insertions, 1 deletions
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;
}
diff --git a/object.c b/object.c
index 2c9cbe7403..9243df5587 100644
--- a/object.c
+++ b/object.c
@@ -1689,7 +1689,6 @@ static VALUE rb_mod_initialize_exec(VALUE module);
static VALUE
rb_mod_initialize(VALUE module)
{
- rb_module_check_initializable(module);
return rb_mod_initialize_exec(module);
}
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index e1524a5d81..b84a090fce 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -519,6 +519,16 @@ class TestModule < Test::Unit::TestCase
assert_raise(ArgumentError) { Module.new { include } }
end
+ def test_include_before_initialize
+ m = Class.new(Module) do
+ def initialize(...)
+ include Enumerable
+ super
+ end
+ end.new
+ assert_equal(true, m < Enumerable)
+ end
+
def test_prepend_self
m = Module.new
assert_equal([m], m.ancestors)