ruby-changes:69766
From: Jean <ko1@a...>
Date: Wed, 17 Nov 2021 06:38:17 +0900 (JST)
Subject: [ruby-changes:69766] 1af8ed5f0a (master): `Primitive.mandatory_only?` consider splat args
https://git.ruby-lang.org/ruby.git/commit/?id=1af8ed5f0a From 1af8ed5f0a2c381c5dee4a5bcffff61f270c30d9 Mon Sep 17 00:00:00 2001 From: Jean Boussier <jean.boussier@g...> Date: Tue, 16 Nov 2021 11:33:39 +0100 Subject: `Primitive.mandatory_only?` consider splat args `vm_ci_argc` gives the number of arguments, but `*[1, 2, 3]` only counts for one. --- test/ruby/test_time.rb | 4 ++++ vm_insnhelper.c | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb index 702bd07094f..c6736750d54 100644 --- a/test/ruby/test_time.rb +++ b/test/ruby/test_time.rb @@ -241,6 +241,10 @@ class TestTime < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_time.rb#L241 assert_equal(1, Time.at(0, 0.001).nsec) end + def test_at_splat + assert_equal(Time.at(1, 2), Time.at(*[1, 2])) + end + def test_at_with_unit assert_equal(123456789, Time.at(0, 123456789, :nanosecond).nsec) assert_equal(123456789, Time.at(0, 123456789, :nsec).nsec) diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 8e0793e0705..9974a8a4f8e 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -1848,8 +1848,10 @@ vm_search_cc(const VALUE klass, const struct rb_callinfo * const ci) https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1848 } } - if ((cme->def->iseq_overload && - (int)vm_ci_argc(ci) == method_entry_iseqptr(cme)->body->param.lead_num)) { + if (cme->def->iseq_overload && + (vm_ci_flag(ci) & (VM_CALL_ARGS_SIMPLE)) && + (int)vm_ci_argc(ci) == method_entry_iseqptr(cme)->body->param.lead_num + ) { // use alternative cme = overloaded_cme(cme); METHOD_ENTRY_CACHED_SET((struct rb_callable_method_entry_struct *)cme); -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/