Skip to content

Commit d1bdc31

Browse files
committed
wip
1 parent 10876c2 commit d1bdc31

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

bootstraptest/test_yjit.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4585,3 +4585,13 @@ def foo(&) = self.class.name(&)
45854585
new.foo
45864586
end
45874587
}
4588+
4589+
# regression test for splat with &proc{} when the target has rest (Bug #21266)
4590+
assert_equal '[]', %q{
4591+
def foo(args) = bar(*args, &proc { _1 })
4592+
def bar(_, _, _, _, *rest) = yield rest
4593+
4594+
GC.stress = true
4595+
foo([1,2,3,4])
4596+
foo([1,2,3,4])
4597+
}

test/ruby/test_yjit.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,6 +1526,18 @@ def test_disable_stats
15261526
assert_in_out_err(%w[--yjit-stats --yjit-disable])
15271527
end
15281528

1529+
def test_proc_block_with_kwrest
1530+
# When the bug was present this required --yjit-stats to trigger.
1531+
assert_compiles(<<~RUBY, result: {extra: 5})
1532+
def foo = bar(w: 1, x: 2, y: 3, z: 4, extra: 5, &proc { _1 })
1533+
def bar(w:, x:, y:, z:, **kwrest) = yield kwrest
1534+
1535+
GC.stress = true
1536+
foo
1537+
foo
1538+
RUBY
1539+
end
1540+
15291541
private
15301542

15311543
def code_gc_helpers

0 commit comments

Comments
 (0)