Skip to content

Commit dcb9ded

Browse files
[PRISM] Fix CallNode with arguments when popped
Previously emitting a call node with an argument followed by another node would cause the argument to be mistakenly omitted from the argument list causing a stack underflow. ``` PRISM: ************************************************** -- raw disasm-------- 0000 putself ( 0) 0001 send <calldata:puts, 1>, nil ( 0) * 0004 pop ( 0) 0005 putobject 1 ( 0) 0007 leave ( 0) --------------------- ```
1 parent 5cff4c5 commit dcb9ded

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

prism_compile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1403,7 +1403,7 @@ pm_setup_args(pm_arguments_node_t *arguments_node, int *flags, struct rb_callinf
14031403
default: {
14041404
orig_argc++;
14051405
post_splat_counter++;
1406-
PM_COMPILE(argument);
1406+
PM_COMPILE_NOT_POPPED(argument);
14071407

14081408
if (has_splat) {
14091409
// If the next node starts the keyword section of parameters

test/ruby/test_compile_prism.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,12 @@ def test_BlockLocalVariableNode
694694

695695
def test_CallNode
696696
assert_prism_eval("to_s")
697+
698+
# with arguments
699+
assert_prism_eval("eval '1'")
700+
701+
# with arguments and popped
702+
assert_prism_eval("eval '1'; 1")
697703
end
698704

699705
def test_CallAndWriteNode

0 commit comments

Comments
 (0)