Permalink
Browse files

vm_insnhelper.c: disable fastpath if splat

* vm_insnhelper.c (vm_callee_setup_arg): disable fastpath if splat
  argument, since argc may differ for each calls.
  [ruby-core:61422] [Bug #9622]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
1 parent ab9e4d1 commit c28b5723f6615fa429fc5b2606eb1b5b43bdb197 @nobu nobu committed Mar 12, 2014
Showing with 23 additions and 2 deletions.
  1. +5 −1 ChangeLog
  2. +15 −0 test/ruby/test_call.rb
  3. +3 −1 vm_insnhelper.c
View
@@ -1,4 +1,8 @@
-Wed Mar 12 11:18:40 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed Mar 12 11:19:03 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * vm_insnhelper.c (vm_callee_setup_arg): disable fastpath if splat
+ argument, since argc may differ for each calls.
+ [ruby-core:61422] [Bug #9622]
* vm_insnhelper.c (vm_callee_setup_arg): turn a macro into an
inline function.
View
@@ -16,4 +16,19 @@ def test_call
assert_equal([1, 2, 3, 4], aaa(1, 2, 3, 4))
assert_equal([1, 2, 3, 4], aaa(1, *[2, 3, 4]))
end
+
+ def test_callinfo
+ bug9622 = '[ruby-core:61422] [Bug #9622]'
+ o = Class.new do
+ def foo(*args)
+ bar(:foo, *args)
+ end
+ def bar(name)
+ name
+ end
+ end.new
+ e = assert_raise(ArgumentError) {o.foo(100)}
+ assert_nothing_raised(ArgumentError) {o.foo}
+ assert_raise_with_message(ArgumentError, e.message, bug9622) {o.foo(100)}
+ end
end
View
@@ -1210,7 +1210,9 @@ vm_callee_setup_arg(rb_thread_t *th, rb_call_info_t *ci, const rb_iseq_t *iseq,
(UNLIKELY(ci->flag & VM_CALL_TAILCALL) ?
vm_call_iseq_setup_tailcall :
vm_call_iseq_setup_normal),
- !is_lambda && !(ci->me->flag & NOEX_PROTECTED));
+ (!is_lambda &&
+ !(ci->flag & VM_CALL_ARGS_SPLAT) && /* argc may differ for each calls */
+ !(ci->me->flag & NOEX_PROTECTED)));
}
else {
ci->aux.opt_pc = vm_callee_setup_arg_complex(th, ci, iseq, argv);

0 comments on commit c28b572

Please sign in to comment.