Skip to content

Commit

Permalink
Create NoMethodError instance using mrb_obj_new().
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Mar 2, 2017
1 parent 9b176a1 commit fdd9275
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
7 changes: 5 additions & 2 deletions src/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,12 +519,15 @@ MRB_API mrb_noreturn void
mrb_no_method_error(mrb_state *mrb, mrb_sym id, mrb_value args, char const* fmt, ...)
{
mrb_value exc;
mrb_value argv[3];
va_list ap;

va_start(ap, fmt);
exc = mrb_funcall(mrb, mrb_obj_value(E_NOMETHOD_ERROR), "new", 3,
mrb_vformat(mrb, fmt, ap), mrb_symbol_value(id), args);
argv[0] = mrb_vformat(mrb, fmt, ap);
argv[1] = mrb_symbol_value(id);
argv[2] = args;
va_end(ap);
exc = mrb_obj_new(mrb, E_NOMETHOD_ERROR, 3, argv);
mrb_exc_raise(mrb, exc);
}

Expand Down
18 changes: 0 additions & 18 deletions test/t/nomethoderror.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,3 @@
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 fdd9275

Please sign in to comment.