Permalink
Browse files

Merge pull request #485 from beoran/bdm_extend_main_crashes_fix

Bugfix for crash if main was extended with a module.
  • Loading branch information...
2 parents cf2bd34 + 8949e3c commit 4dcd7cdacd6e19a1c5120fa8366a4887e79da5b6 @matz matz committed Oct 10, 2012
Showing with 12 additions and 0 deletions.
  1. +2 −0 src/class.c
  2. +10 −0 test/t/kernel.rb
View
@@ -786,6 +786,8 @@ mrb_singleton_class(mrb_state *mrb, mrb_value v)
return mrb_obj_value(mrb->false_class);
case MRB_TT_TRUE:
return mrb_obj_value(mrb->true_class);
+ case MRB_TT_MAIN:
+ return mrb_obj_value(mrb->object_class);
case MRB_TT_SYMBOL:
case MRB_TT_FIXNUM:
case MRB_TT_FLOAT:
View
@@ -204,6 +204,16 @@ def test_method; end
a.respond_to?(:test_method) == true && b.respond_to?(:test_method) == false
end
+assert('Kernel#extend works on toplevel', '15.3.1.3.13') do
+ module Test4ExtendModule
+ def test_method; end
+ end
+ # This would crash...
+ extend(Test4ExtendModule)
+
+ respond_to?(:test_method) == true
+end
+
assert('Kernel#global_variables', '15.3.1.3.14') do
global_variables.class == Array
end

0 comments on commit 4dcd7cd

Please sign in to comment.