summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-27 10:15:47 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-27 10:15:47 +0000
commit6115f65d7dd29561710c3e84bb27180e5bab4380 (patch)
tree637d955e548699811e54d3044b9bdfa4113a3ba2 /vm_insnhelper.c
parent955c7f0698d2229f72ae9b9d2a49a1cbecb606e9 (diff)
* vm_args.c: fix backtrace location for keyword related exceptions.
For example, the following program def foo(k1: 1); end # line 1 foo(k2: 2) # line 2 causes "unknown keyword: k2 (ArgumentError)". Before this patch, the backtrace location is only line 2. However, error should be located at line 1 (over line 2 in stack trace). This patch fix this problem. * class.c (rb_keyword_error_new): separate exception creation logic from rb_keyword_error(), to use in vm_args.c. * vm_insnhelper.c (rb_arg_error_new): rename to rb_arity_error_new(). * vm_args.c (argument_arity_error): rename to argument_arity_error(). * vm_args.c (arugment_kw_error): added to fix backtrace. * test/ruby/test_keyword.rb: add tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 7bb0aadaa8..edb0e0622d 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -115,7 +115,7 @@ vm_pop_frame(rb_thread_t *th)
/* method dispatch */
static inline VALUE
-rb_arg_error_new(int argc, int min, int max)
+rb_arity_error_new(int argc, int min, int max)
{
VALUE err_mess = 0;
if (min == max) {
@@ -133,7 +133,7 @@ rb_arg_error_new(int argc, int min, int max)
void
rb_error_arity(int argc, int min, int max)
{
- rb_exc_raise(rb_arg_error_new(argc, min, max));
+ rb_exc_raise(rb_arity_error_new(argc, min, max));
}
/* svar */
@@ -1064,7 +1064,7 @@ vm_callee_setup_block_arg(rb_thread_t *th, rb_call_info_t *ci, const rb_iseq_t *
ci->argc = vm_callee_setup_block_arg_arg0_splat(cfp, iseq, argv, arg0);
}
else {
- argument_error(iseq, ci->argc, iseq->param.lead_num, iseq->param.lead_num);
+ argument_arity_error(th, iseq, ci->argc, iseq->param.lead_num, iseq->param.lead_num);
}
}
@@ -1084,7 +1084,7 @@ vm_callee_setup_arg(rb_thread_t *th, rb_call_info_t *ci, const rb_iseq_t *iseq,
CALLER_SETUP_ARG(cfp, ci); /* splat arg */
if (ci->argc != iseq->param.lead_num) {
- argument_error(iseq, ci->argc, iseq->param.lead_num, iseq->param.lead_num);
+ argument_arity_error(th, iseq, ci->argc, iseq->param.lead_num, iseq->param.lead_num);
}
ci->aux.opt_pc = 0;