diff options
author | Jemma Issroff <jemmaissroff@gmail.com> | 2023-12-07 14:13:33 -0500 |
---|---|---|
committer | Jemma Issroff <jemmaissroff@gmail.com> | 2023-12-07 15:29:35 -0500 |
commit | a0c7bb4328c981be5f3f0e82e7ef75fc8bbd51b6 (patch) | |
tree | adf072ec21ffe92d00c4ac9485eb1ac680004438 /prism_compile.c | |
parent | 7738b31d390e70b26e913d86c133a70c8e65a645 (diff) | |
download | ruby-a0c7bb4328c981be5f3f0e82e7ef75fc8bbd51b6.tar.gz |
[PRISM] Account for multiple arguments when compiling ArgumentsNode
BreakNode, ReturnNode and NextNode all compile the ArgumentsNode
directly, but we weren't accounting for multiple arguments. If there
is more than one argument, we need to also emit a newarray
instruction to put the arguments onto the stack
Diffstat (limited to 'prism_compile.c')
-rw-r--r-- | prism_compile.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/prism_compile.c b/prism_compile.c index 1eeecc5c2a..71fd05dddf 100644 --- a/prism_compile.c +++ b/prism_compile.c @@ -1762,6 +1762,9 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret, for (size_t index = 0; index < node_list.size; index++) { PM_COMPILE(node_list.nodes[index]); } + if (node_list.size > 1) { + ADD_INSN1(ret, &dummy_line_node, newarray, INT2FIX(node_list.size)); + } return; } case PM_ARRAY_NODE: { @@ -3578,7 +3581,7 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret, ADD_ADJUST(ret, &dummy_line_node, ISEQ_COMPILE_DATA(iseq)->start_label); if (next_node->arguments) { - PM_COMPILE((pm_node_t *)next_node->arguments); + PM_COMPILE_NOT_POPPED((pm_node_t *)next_node->arguments); } else { PM_PUTNIL; @@ -3618,7 +3621,7 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret, } if (ip != 0) { if (next_node->arguments) { - PM_COMPILE((pm_node_t *)next_node->arguments); + PM_COMPILE_NOT_POPPED((pm_node_t *)next_node->arguments); } else { PM_PUTNIL; |