mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* vm_insnhelper.c (argument_error): push correct backtrace.
Bug #2281 [ruby-core:26333] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
622f45fccb
commit
8ed1f43392
2 changed files with 35 additions and 7 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Tue May 4 12:46:09 2010 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
|
* vm_insnhelper.c (argument_error): push correct backtrace.
|
||||||
|
Bug #2281 [ruby-core:26333]
|
||||||
|
|
||||||
Tue May 4 12:38:40 2010 Tanaka Akira <akr@fsij.org>
|
Tue May 4 12:38:40 2010 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* ext/socket/option.c (sockopt_inspect): use rb_str_cat2 and
|
* ext/socket/option.c (sockopt_inspect): use rb_str_cat2 and
|
||||||
|
|
|
@ -102,11 +102,37 @@ vm_pop_frame(rb_thread_t *th)
|
||||||
|
|
||||||
/* method dispatch */
|
/* method dispatch */
|
||||||
|
|
||||||
|
static void
|
||||||
|
argument_error(const rb_iseq_t *iseq, int miss_argc, int correct_argc)
|
||||||
|
{
|
||||||
|
VALUE mesg = rb_sprintf("wrong number of arguments (%d for %d)", miss_argc, correct_argc);
|
||||||
|
VALUE exc = rb_exc_new3(rb_eArgError, mesg);
|
||||||
|
VALUE bt = rb_make_backtrace();
|
||||||
|
VALUE err_line = 0;
|
||||||
|
|
||||||
|
if (iseq) {
|
||||||
|
int line_no = 1;
|
||||||
|
const char *name;
|
||||||
|
|
||||||
|
if (iseq->insn_info_size) {
|
||||||
|
line_no = iseq->insn_info_table[0].line_no;
|
||||||
|
}
|
||||||
|
|
||||||
|
err_line = rb_sprintf("%s:%d:in `%s'",
|
||||||
|
RSTRING_PTR(iseq->filename),
|
||||||
|
line_no, RSTRING_PTR(iseq->name));
|
||||||
|
rb_funcall(bt, rb_intern("unshift"), 1, err_line);
|
||||||
|
}
|
||||||
|
|
||||||
|
rb_funcall(exc, rb_intern("set_backtrace"), 1, bt);
|
||||||
|
rb_exc_raise(exc);
|
||||||
|
}
|
||||||
|
|
||||||
#define VM_CALLEE_SETUP_ARG(ret, th, iseq, orig_argc, orig_argv, block) \
|
#define VM_CALLEE_SETUP_ARG(ret, th, iseq, orig_argc, orig_argv, block) \
|
||||||
if (LIKELY(iseq->arg_simple & 0x01)) { \
|
if (LIKELY(iseq->arg_simple & 0x01)) { \
|
||||||
/* simple check */ \
|
/* simple check */ \
|
||||||
if (orig_argc != iseq->argc) { \
|
if (orig_argc != iseq->argc) { \
|
||||||
rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)", orig_argc, iseq->argc); \
|
argument_error(iseq, orig_argc, iseq->argc); \
|
||||||
} \
|
} \
|
||||||
ret = 0; \
|
ret = 0; \
|
||||||
} \
|
} \
|
||||||
|
@ -128,8 +154,7 @@ vm_callee_setup_arg_complex(rb_thread_t *th, const rb_iseq_t * iseq,
|
||||||
|
|
||||||
/* mandatory */
|
/* mandatory */
|
||||||
if (argc < (m + iseq->arg_post_len)) { /* check with post arg */
|
if (argc < (m + iseq->arg_post_len)) { /* check with post arg */
|
||||||
rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)",
|
argument_error(iseq, argc, m + iseq->arg_post_len);
|
||||||
argc, m + iseq->arg_post_len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
argv += m;
|
argv += m;
|
||||||
|
@ -152,8 +177,7 @@ vm_callee_setup_arg_complex(rb_thread_t *th, const rb_iseq_t * iseq,
|
||||||
const int opts = iseq->arg_opts - 1 /* no opt */;
|
const int opts = iseq->arg_opts - 1 /* no opt */;
|
||||||
|
|
||||||
if (iseq->arg_rest == -1 && argc > opts) {
|
if (iseq->arg_rest == -1 && argc > opts) {
|
||||||
rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)",
|
argument_error(iseq, orig_argc, m + opts + iseq->arg_post_len);
|
||||||
orig_argc, m + opts + iseq->arg_post_len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc > opts) {
|
if (argc > opts) {
|
||||||
|
@ -183,8 +207,7 @@ vm_callee_setup_arg_complex(rb_thread_t *th, const rb_iseq_t * iseq,
|
||||||
const rb_block_t *blockptr = *block;
|
const rb_block_t *blockptr = *block;
|
||||||
|
|
||||||
if (argc != 0) {
|
if (argc != 0) {
|
||||||
rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)",
|
argument_error(iseq, orig_argc, m + iseq->arg_post_len);
|
||||||
orig_argc, m + iseq->arg_post_len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockptr) {
|
if (blockptr) {
|
||||||
|
|
Loading…
Reference in a new issue