Entrust "no block given" error to `mrb_get_args()`
Some error messages will be changed.
MODIFY
mrbgems/mruby-class-ext/src/class.c
mrbgems/mruby-class-ext/src/class.c
@@ -40,11 +40,7 @@ mrb_mod_module_exec(mrb_state *mrb, mrb_value self)
mrb_int argc;
mrb_value blk;
- mrb_get_args(mrb, "*&", &argv, &argc, &blk);
-
- if (mrb_nil_p(blk)) {
- mrb_raise(mrb, E_ARGUMENT_ERROR, "no block given");
- }
+ mrb_get_args(mrb, "*&!", &argv, &argc, &blk);
mrb->c->ci->target_class = mrb_class_ptr(self);
return mrb_yield_cont(mrb, blk, self, argc, argv);

MODIFY
mrbgems/mruby-fiber/src/fiber.c
mrbgems/mruby-fiber/src/fiber.c
@@ -72,14 +72,11 @@ fiber_init(mrb_state *mrb, mrb_value self)
mrb_value blk;
size_t slen;
- mrb_get_args(mrb, "&", &blk);
+ mrb_get_args(mrb, "&!", &blk);
if (f->cxt) {
mrb_raise(mrb, E_RUNTIME_ERROR, "cannot initialize twice");
}
- if (mrb_nil_p(blk)) {
- mrb_raise(mrb, E_ARGUMENT_ERROR, "tried to create Fiber object without a block");
- }
p = mrb_proc_ptr(blk);
if (MRB_PROC_CFUNC_P(p)) {
mrb_raise(mrb, E_FIBER_ERROR, "tried to create Fiber from C defined method");

MODIFY
mrbgems/mruby-metaprog/src/metaprog.c
mrbgems/mruby-metaprog/src/metaprog.c
@@ -389,10 +389,7 @@ mod_define_singleton_method(mrb_state *mrb, mrb_value self)
mrb_sym mid;
mrb_value blk = mrb_nil_value();
- mrb_get_args(mrb, "n&", &mid, &blk);
- if (mrb_nil_p(blk)) {
- mrb_raise(mrb, E_ARGUMENT_ERROR, "no block given");
- }
+ mrb_get_args(mrb, "n&!", &mid, &blk);
p = (struct RProc*)mrb_obj_alloc(mrb, MRB_TT_PROC, mrb->proc_class);
mrb_proc_copy(p, mrb_proc_ptr(blk));
p->flags |= MRB_PROC_STRICT;

MODIFY
mrbgems/mruby-object-ext/src/object.c
mrbgems/mruby-object-ext/src/object.c
@@ -100,11 +100,7 @@ mrb_obj_instance_exec(mrb_state *mrb, mrb_value self)
mrb_value blk;
struct RClass *c;
- mrb_get_args(mrb, "*&", &argv, &argc, &blk);
-
- if (mrb_nil_p(blk)) {
- mrb_raise(mrb, E_ARGUMENT_ERROR, "no block given");
- }
+ mrb_get_args(mrb, "*&!", &argv, &argc, &blk);
switch (mrb_type(self)) {
case MRB_TT_SYMBOL:

MODIFY
mrbgems/mruby-objectspace/src/mruby_objectspace.c
mrbgems/mruby-objectspace/src/mruby_objectspace.c
@@ -161,11 +161,7 @@ os_each_object(mrb_state *mrb, mrb_value self)
{
mrb_value cls = mrb_nil_value();
struct os_each_object_data d;
- mrb_get_args(mrb, "&|C", &d.block, &cls);
-
- if (mrb_nil_p(d.block)) {
- mrb_raise(mrb, E_ARGUMENT_ERROR, "Expected block in ObjectSpace.each_object.");
- }
+ mrb_get_args(mrb, "&!|C", &d.block, &cls);
d.target_module = mrb_nil_p(cls) ? NULL : mrb_class_ptr(cls);
d.count = 0;

MODIFY
mrbgems/mruby-proc-ext/src/proc.c
mrbgems/mruby-proc-ext/src/proc.c
@@ -72,10 +72,7 @@ mrb_kernel_proc(mrb_state *mrb, mrb_value self)
{
mrb_value blk;
- mrb_get_args(mrb, "&", &blk);
- if (mrb_nil_p(blk)) {
- mrb_raise(mrb, E_ARGUMENT_ERROR, "tried to create Proc object without a block");
- }
+ mrb_get_args(mrb, "&!", &blk);
return blk;
}

MODIFY
src/proc.c
src/proc.c
@@ -184,11 +184,8 @@ mrb_proc_s_new(mrb_state *mrb, mrb_value proc_class)
mrb_value proc;
struct RProc *p;
- mrb_get_args(mrb, "&", &blk);
- if (mrb_nil_p(blk)) {
/* Calling Proc.new without a block is not implemented yet */
- mrb_raise(mrb, E_ARGUMENT_ERROR, "tried to create Proc object without a block");
- }
+ mrb_get_args(mrb, "&!", &blk);
p = (struct RProc *)mrb_obj_alloc(mrb, MRB_TT_PROC, mrb_class_ptr(proc_class));
mrb_proc_copy(p, mrb_proc_ptr(blk));
proc = mrb_obj_value(p);

Entrust "no block given" error to `mrb_get_args()`

Some error messages will be changed.