diff --git a/compile.c b/compile.c index f1dd595e3d..1336982d32 100644 --- a/compile.c +++ b/compile.c @@ -7259,6 +7259,7 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c case NODE_COLON3: case NODE_BEGIN: case NODE_BLOCK: + case NODE_ONCE: CHECK(COMPILE(ret, "case in literal", node)); // (1) if (in_single_pattern) { ADD_INSN1(ret, line_node, dupn, INT2FIX(2)); diff --git a/test/ruby/test_pattern_matching.rb b/test/ruby/test_pattern_matching.rb index 8e2806581c..db6ad06b82 100644 --- a/test/ruby/test_pattern_matching.rb +++ b/test/ruby/test_pattern_matching.rb @@ -353,6 +353,14 @@ END end end + assert_block do + a = "abc" + case 'abc' + in /#{a}/o + true + end + end + assert_block do case 0 in ->(i) { i == 0 }