Skip to content
Browse files

`catch' accepts one or no argument

  • Loading branch information...
1 parent c1cc109 commit 960fa9bfade7071060deac8c142f57ba19a1a05e @Watson1978 Watson1978 committed Jun 27, 2012
Showing with 9 additions and 3 deletions.
  1. +0 −1 spec/frozen/tags/macruby/core/kernel/catch_tags.txt
  2. +9 −2 vm_eval.c
View
1 spec/frozen/tags/macruby/core/kernel/catch_tags.txt
@@ -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
View
11 vm_eval.c
@@ -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);
}
@@ -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);

0 comments on commit 960fa9b

Please sign in to comment.
Something went wrong with that request. Please try again.