diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-02-17 10:57:22 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-17 10:57:22 +0900 |
commit | dd28c55a7cd6780dad637b4d6a20507fbfc6af4a (patch) | |
tree | 213b5fc66d0e64bac3565334fe4c5e6185cdc3fc | |
parent | a4b7ec12298c78392797e5ba7704076550e4f100 (diff) | |
download | ruby-dd28c55a7cd6780dad637b4d6a20507fbfc6af4a.tar.gz |
[Bug#19445] Fix keyword splat in enumerator
Extracted arguments do not have keyword hash to splat.
-rw-r--r-- | numeric.c | 2 | ||||
-rw-r--r-- | test/ruby/test_numeric.rb | 3 |
2 files changed, 4 insertions, 1 deletions
@@ -3065,7 +3065,7 @@ num_step(int argc, VALUE *argv, VALUE from) num_step_size, from, to, step, FALSE); } - return SIZED_ENUMERATOR(from, 2, ((VALUE [2]){to, step}), num_step_size); + return SIZED_ENUMERATOR_KW(from, 2, ((VALUE [2]){to, step}), num_step_size, FALSE); } desc = num_step_scan_args(argc, argv, &to, &step, TRUE, FALSE); diff --git a/test/ruby/test_numeric.rb b/test/ruby/test_numeric.rb index 0593cb535d..ab492743f6 100644 --- a/test/ruby/test_numeric.rb +++ b/test/ruby/test_numeric.rb @@ -324,6 +324,9 @@ class TestNumeric < Test::Unit::TestCase e = 1.step(10, {by: "1"}) assert_raise(TypeError) {e.next} assert_raise(TypeError) {e.size} + e = 1.step(to: "10") + assert_raise(ArgumentError) {e.next} + assert_raise(ArgumentError) {e.size} assert_equal(bignum*2+1, (-bignum).step(bignum, 1).size) assert_equal(bignum*2, (-bignum).step(bignum-1, 1).size) |