Permalink
Browse files

Fix 36fc1f1 not checking in the right location

  • Loading branch information...
bouk authored and clayton-shopify committed Dec 6, 2016
1 parent db1bd07 commit 6be5160eb634e7b045cba83a38675cf14fa16593
Showing with 21 additions and 2 deletions.
  1. +3 −2 src/error.c
  2. +18 −0 test/t/nomethoderror.rb
View
@@ -280,15 +280,16 @@ mrb_exc_set(mrb_state *mrb, mrb_value exc)
mrb->exc = 0;
}
else {
if (!mrb_obj_is_kind_of(mrb, exc, mrb->eException_class))
mrb_raise(mrb, E_TYPE_ERROR, "exception object expected");
mrb->exc = mrb_obj_ptr(exc);
}
}
MRB_API mrb_noreturn void
mrb_exc_raise(mrb_state *mrb, mrb_value exc)
{
if (!mrb_obj_is_kind_of(mrb, exc, mrb->eException_class)) {
mrb_raise(mrb, E_TYPE_ERROR, "exception object expected");
}
mrb_exc_set(mrb, exc);
if (!mrb->gc.out_of_memory) {
exc_debug_info(mrb, mrb->exc);
View
@@ -51,3 +51,21 @@ def foo
end
end
end
assert("NoMethodError#new does not return an exception") do
begin
class << NoMethodError
def new(*)
nil
end
end
assert_raise(TypeError) do
Object.q
end
ensure
class << NoMethodError
remove_method :new
end
end
end

0 comments on commit 6be5160

Please sign in to comment.