[Bug#19445] Fix keyword splat in enumerator

Extracted arguments do not have keyword hash to splat.
This commit is contained in:
Nobuyoshi Nakada 2023-02-17 10:57:22 +09:00 committed by GitHub
parent a4b7ec1229
commit dd28c55a7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
Notes: git 2023-02-17 01:57:42 +00:00
Merged: https://github.com/ruby/ruby/pull/7325

Merged-By: nobu <nobu@ruby-lang.org>
2 changed files with 4 additions and 1 deletions

View File

@ -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);

View File

@ -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)