[PRISM] Fix popped for AssocSplatNode

This commit is contained in:
Jemma Issroff 2023-11-02 14:56:40 -03:00
Родитель 8b4b3b1d38
Коммит 62baf723b6
2 изменённых файлов: 4 добавлений и 3 удалений

Просмотреть файл

@ -2400,7 +2400,7 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
int elements_of_cur_type = 0; int elements_of_cur_type = 0;
int allocated_hashes = 0; int allocated_hashes = 0;
if (!PM_NODE_TYPE_P(cur_node, PM_ASSOC_NODE)) { if (!PM_NODE_TYPE_P(cur_node, PM_ASSOC_NODE) && !popped) {
ADD_INSN1(ret, &dummy_line_node, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE)); ADD_INSN1(ret, &dummy_line_node, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
ADD_INSN1(ret, &dummy_line_node, newhash, INT2FIX(0)); ADD_INSN1(ret, &dummy_line_node, newhash, INT2FIX(0));
allocated_hashes++; allocated_hashes++;
@ -2435,6 +2435,9 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
PM_COMPILE(elements->nodes[index]); PM_COMPILE(elements->nodes[index]);
} }
} }
else {
PM_COMPILE(elements->nodes[index]);
}
} }
if (!popped) { if (!popped) {

Просмотреть файл

@ -441,11 +441,9 @@ module Prism
end end
def test_AssocSplatNode def test_AssocSplatNode
=begin
assert_prism_eval("foo = { a: 1 }; { **foo }") assert_prism_eval("foo = { a: 1 }; { **foo }")
assert_prism_eval("foo = { a: 1 }; bar = foo; { **foo, b: 2, **bar, c: 3 }") assert_prism_eval("foo = { a: 1 }; bar = foo; { **foo, b: 2, **bar, c: 3 }")
assert_prism_eval("foo = { a: 1 }; { b: 2, **foo, c: 3}") assert_prism_eval("foo = { a: 1 }; { b: 2, **foo, c: 3}")
=end
end end
def test_HashNode def test_HashNode