Support NODE_ONCE for pattern matching

This commit is contained in:
S-H-GAMELINKS 2024-02-01 19:50:40 +09:00 committed by Kazuki Tsujimoto
parent 5621d794a2
commit 2d8788e90c
2 changed files with 9 additions and 0 deletions

View File

@ -7259,6 +7259,7 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
case NODE_COLON3: case NODE_COLON3:
case NODE_BEGIN: case NODE_BEGIN:
case NODE_BLOCK: case NODE_BLOCK:
case NODE_ONCE:
CHECK(COMPILE(ret, "case in literal", node)); // (1) CHECK(COMPILE(ret, "case in literal", node)); // (1)
if (in_single_pattern) { if (in_single_pattern) {
ADD_INSN1(ret, line_node, dupn, INT2FIX(2)); ADD_INSN1(ret, line_node, dupn, INT2FIX(2));

View File

@ -353,6 +353,14 @@ END
end end
end end
assert_block do
a = "abc"
case 'abc'
in /#{a}/o
true
end
end
assert_block do assert_block do
case 0 case 0
in ->(i) { i == 0 } in ->(i) { i == 0 }