[PRISM] Implement CallNodes with splat followed by args

This commit is contained in:
Jemma Issroff 2023-11-29 14:58:26 -05:00
parent 2233204cc1
commit 853fd44745
2 changed files with 20 additions and 5 deletions

View File

@ -1022,9 +1022,17 @@ pm_setup_args(pm_arguments_node_t *arguments_node, int *flags, struct rb_callinf
} }
// If it's the final node // If it's the final node
else if (index == arguments_node_list.size - 1) { else if (index == arguments_node_list.size - 1) {
if (post_splat_counter > 1) {
ADD_INSN1(ret, &dummy_line_node, newarray, INT2FIX(post_splat_counter));
ADD_INSN1(ret, &dummy_line_node, splatarray, Qfalse);
ADD_INSN(ret, &dummy_line_node, concatarray);
}
else {
ADD_INSN1(ret, &dummy_line_node, newarray, INT2FIX(post_splat_counter)); ADD_INSN1(ret, &dummy_line_node, newarray, INT2FIX(post_splat_counter));
ADD_INSN(ret, &dummy_line_node, concatarray); ADD_INSN(ret, &dummy_line_node, concatarray);
} }
orig_argc = 1;
}
} }
} }
} }

View File

@ -935,12 +935,19 @@ module Prism
# With different types of calling arguments # With different types of calling arguments
assert_prism_eval(<<-CODE) assert_prism_eval(<<-CODE)
def self.prism_test_call_node(**); end def self.prism_test_call_node_double_splat(**); end
prism_test_call_node(b: 1, **{}) prism_test_call_node_double_splat(b: 1, **{})
CODE CODE
assert_prism_eval(<<-CODE) assert_prism_eval(<<-CODE)
prism_test_call_node(:b => 1) prism_test_call_node_double_splat(:b => 1)
CODE CODE
assert_prism_eval(<<-CODE)
def self.prism_test_call_node_splat(*); end
prism_test_call_node_splat(*[], 1)
CODE
assert_prism_eval("prism_test_call_node_splat(*[], 1, 2)")
end end
def test_CallAndWriteNode def test_CallAndWriteNode