Support NODE_ONCE for pattern matching
This commit is contained in:
parent
5621d794a2
commit
2d8788e90c
@ -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));
|
||||||
|
@ -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 }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user