summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-03-14 21:10:34 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-03-14 21:10:34 +0000
commit7316302483182a73136b00ad368585e551cbd86f (patch)
treed32188711001581a5e7e21d6669f6c4e91fcb497 /proc.c
parent35c356ea72094dbbf1397d8f5acd065bd23d1177 (diff)
* include/ruby/intern.h: Add rb_check_arity, rb_error_arity [#6085]
* array.c: Use rb_check_arity / rb_error_arity * class.c: ditto * enumerator.c: ditto * eval.c: ditto * file.c: ditto * hash.c: ditto * numeric.c: ditto * proc.c: ditto * process.c: ditto * random.c: ditto * re.c: ditto * signal.c: ditto * string.c: ditto * struct.c: ditto * transcode.c: ditto * vm_eval.c: ditto * vm_insnhelper.c: ditto & implementation of rb_error_arity * test/ruby/test_arity.rb: tests for above git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/proc.c b/proc.c
index 1ea190c3b3..8dcdf8fc3a 100644
--- a/proc.c
+++ b/proc.c
@@ -1350,7 +1350,8 @@ rb_mod_define_method(int argc, VALUE *argv, VALUE mod)
id = rb_to_id(argv[0]);
body = rb_block_lambda();
}
- else if (argc == 2) {
+ else {
+ rb_check_arity(argc, 1, 2);
id = rb_to_id(argv[0]);
body = argv[1];
if (!rb_obj_is_method(body) && !rb_obj_is_proc(body)) {
@@ -1359,9 +1360,6 @@ rb_mod_define_method(int argc, VALUE *argv, VALUE mod)
rb_obj_classname(body));
}
}
- else {
- rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", argc);
- }
if (rb_obj_is_method(body)) {
struct METHOD *method = (struct METHOD *)DATA_PTR(body);