mirror of
https://github.com/ruby/ruby.git
synced 2025-08-23 21:14:23 +02:00
[PRISM] Don't pop several args related nodes
This commit is contained in:
parent
150ed44d87
commit
6d447fa35f
2 changed files with 15 additions and 6 deletions
|
@ -1354,8 +1354,8 @@ pm_setup_args(pm_arguments_node_t *arguments_node, int *flags, struct rb_callinf
|
|||
case PM_ASSOC_NODE: {
|
||||
pm_assoc_node_t *assoc = (pm_assoc_node_t *)cur_node;
|
||||
|
||||
PM_COMPILE(assoc->key);
|
||||
PM_COMPILE(assoc->value);
|
||||
PM_COMPILE_NOT_POPPED(assoc->key);
|
||||
PM_COMPILE_NOT_POPPED(assoc->value);
|
||||
cur_hash_size++;
|
||||
|
||||
// If we're at the last keyword arg, or the last assoc node of this "set",
|
||||
|
@ -1386,7 +1386,7 @@ pm_setup_args(pm_arguments_node_t *arguments_node, int *flags, struct rb_callinf
|
|||
}
|
||||
|
||||
pm_assoc_splat_node_t *assoc_splat = (pm_assoc_splat_node_t *)cur_node;
|
||||
PM_COMPILE(assoc_splat->value);
|
||||
PM_COMPILE_NOT_POPPED(assoc_splat->value);
|
||||
|
||||
*flags |= VM_CALL_KW_SPLAT | VM_CALL_KW_SPLAT_MUT;
|
||||
|
||||
|
@ -1411,14 +1411,14 @@ pm_setup_args(pm_arguments_node_t *arguments_node, int *flags, struct rb_callinf
|
|||
}
|
||||
else {
|
||||
*kw_arg = rb_xmalloc_mul_add(len, sizeof(VALUE), sizeof(struct rb_callinfo_kwarg));
|
||||
*flags |= VM_CALL_KWARG;
|
||||
(*kw_arg)->keyword_len += len;
|
||||
*flags = VM_CALL_KWARG;
|
||||
(*kw_arg)->keyword_len = (int) len;
|
||||
|
||||
// TODO: Method callers like `foo(a => b)`
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
pm_assoc_node_t *assoc = (pm_assoc_node_t *)keyword_arg->elements.nodes[i];
|
||||
(*kw_arg)->keywords[i] = pm_static_literal_value(assoc->key, scope_node, parser);
|
||||
PM_COMPILE(assoc->value);
|
||||
PM_COMPILE_NOT_POPPED(assoc->value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -804,6 +804,15 @@ module Prism
|
|||
|
||||
# with arguments and popped
|
||||
assert_prism_eval("eval '1'; 1")
|
||||
|
||||
# With different types of calling arguments
|
||||
assert_prism_eval(<<-CODE)
|
||||
def self.prism_test_call_node(**); end
|
||||
prism_test_call_node(b: 1, **{})
|
||||
CODE
|
||||
assert_prism_eval(<<-CODE)
|
||||
prism_test_call_node(:b => 1)
|
||||
CODE
|
||||
end
|
||||
|
||||
def test_CallAndWriteNode
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue