diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-03-02 10:56:23 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-03-02 10:56:23 +0900 |
| commit | fdd92750fe7e65150b067bc5179e813e7b5e2312 (patch) | |
| tree | 4383a1227df4762e728fd02635be5084f3e19a50 | |
| parent | 9b176a1ca8249de38a056ad075e10277300c03a2 (diff) | |
| download | mruby-fdd92750fe7e65150b067bc5179e813e7b5e2312.tar.gz mruby-fdd92750fe7e65150b067bc5179e813e7b5e2312.zip | |
Create NoMethodError instance using `mrb_obj_new()`.
| -rw-r--r-- | src/error.c | 7 | ||||
| -rw-r--r-- | test/t/nomethoderror.rb | 18 |
2 files changed, 5 insertions, 20 deletions
diff --git a/src/error.c b/src/error.c index 3fa18fcb3..931361763 100644 --- a/src/error.c +++ b/src/error.c @@ -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); } diff --git a/test/t/nomethoderror.rb b/test/t/nomethoderror.rb index 22a5f8a0e..5fed79689 100644 --- a/test/t/nomethoderror.rb +++ b/test/t/nomethoderror.rb @@ -20,21 +20,3 @@ assert('NoMethodError#args', '15.2.32.2.1') do 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 |
