зеркало из https://github.com/github/ruby.git
[PRISM] Fix splat and block in aset
This commit is contained in:
Родитель
1847192366
Коммит
1838dbf6e7
|
@ -2713,6 +2713,10 @@ pm_compile_call(rb_iseq_t *iseq, const pm_call_node_t *call_node, LINK_ANCHOR *c
|
|||
if (pm_node->flags & PM_CALL_NODE_FLAGS_ATTRIBUTE_WRITE) {
|
||||
if (flags & VM_CALL_ARGS_BLOCKARG) {
|
||||
ADD_INSN1(ret, &dummy_line_node, topn, INT2FIX(1));
|
||||
if (flags & VM_CALL_ARGS_SPLAT) {
|
||||
ADD_INSN1(ret, &dummy_line_node, putobject, INT2FIX(-1));
|
||||
ADD_SEND_WITH_FLAG(ret, &dummy_line_node, idAREF, INT2FIX(1), INT2FIX(0));
|
||||
}
|
||||
ADD_INSN1(ret, &dummy_line_node, setn, INT2FIX(orig_argc + 3));
|
||||
PM_POP;
|
||||
}
|
||||
|
|
|
@ -1771,6 +1771,15 @@ end
|
|||
obj[&p] = 4
|
||||
RUBY
|
||||
|
||||
# Test splat and block inside of []=
|
||||
assert_prism_eval(<<~RUBY)
|
||||
obj = Object.new
|
||||
def obj.[]=(a, b); end
|
||||
|
||||
p = proc {}
|
||||
obj[*[1], &p] = 4
|
||||
RUBY
|
||||
|
||||
assert_prism_eval(<<-CODE)
|
||||
def self.prism_opt_var_trail_hash(a = nil, *b, c, **d); end
|
||||
prism_opt_var_trail_hash("a")
|
||||
|
|
Загрузка…
Ссылка в новой задаче