Skip to content

Commit

Permalink
Merge pull request mruby#485 from beoran/bdm_extend_main_crashes_fix
Browse files Browse the repository at this point in the history
Bugfix for crash if main was extended with a module.
  • Loading branch information
matz committed Oct 10, 2012
2 parents cf2bd34 + 8949e3c commit 4dcd7cd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/class.c
Expand Up @@ -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:
Expand Down
10 changes: 10 additions & 0 deletions test/t/kernel.rb
Expand Up @@ -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
Expand Down

0 comments on commit 4dcd7cd

Please sign in to comment.