Skip to content

Commit bc005cc

Browse files
committed
Add pushtoarray insn to fix segfault with forwarding + splat
1 parent 7c91db9 commit bc005cc

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

bootstraptest/test_method.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,3 +1427,10 @@ def test(*, kw: false)
14271427
14281428
test
14291429
RUBY
1430+
1431+
assert_equal '[1, 2, 3]', %q{
1432+
def target(*args) = args
1433+
def x = [1]
1434+
def forwarder(...) = target(*x, 2, ...)
1435+
forwarder(3).inspect
1436+
}, '[Bug #21192] post-splat args before forwarding'

prism_compile.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,6 +1855,11 @@ pm_setup_args_core(const pm_arguments_node_t *arguments_node, const pm_node_t *b
18551855
PUSH_INSN(ret, location, concatarray);
18561856
break;
18571857
}
1858+
case PM_FORWARDING_ARGUMENTS_NODE: {
1859+
// foo(*a, b, ...) - push into splat for correct stack layout
1860+
PUSH_INSN1(ret, location, pushtoarray, INT2FIX(post_splat_counter));
1861+
break;
1862+
}
18581863
default:
18591864
break;
18601865
}

0 commit comments

Comments
 (0)