Skip to content

Commit

Permalink
`catch' accepts one or no argument
Browse files Browse the repository at this point in the history
  • Loading branch information
Watson1978 committed Jun 26, 2012
1 parent c1cc109 commit 960fa9b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 0 additions & 1 deletion spec/frozen/tags/macruby/core/kernel/catch_tags.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
fails:Kernel.catch yields a new, unique object when called without arguments
fails:Kernel.catch yields an object when called without arguments
11 changes: 9 additions & 2 deletions vm_eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,8 +682,15 @@ rb_throw_obj(VALUE tag, VALUE val)
*/

static VALUE
rb_f_catch(VALUE rcv, SEL sel, VALUE tag)
rb_f_catch(VALUE rcv, SEL sel, int argc, VALUE *argv)
{
VALUE tag;
if (argc == 0) {
tag = rb_obj_alloc(rb_cObject);
}
else {
rb_scan_args(argc, argv, "01", &tag);
}
return rb_vm_catch(tag);
}

Expand Down Expand Up @@ -751,7 +758,7 @@ rb_make_backtrace(void)
void
Init_vm_eval(void)
{
rb_objc_define_module_function(rb_mKernel, "catch", rb_f_catch, 1);
rb_objc_define_module_function(rb_mKernel, "catch", rb_f_catch, -1);
rb_objc_define_module_function(rb_mKernel, "throw", rb_f_throw, -1);

rb_objc_define_module_function(rb_mKernel, "loop", rb_f_loop, 0);
Expand Down

0 comments on commit 960fa9b

Please sign in to comment.