aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--compile.c2
-rw-r--r--test/ruby/test_pattern_matching.rb10
2 files changed, 11 insertions, 1 deletions
diff --git a/compile.c b/compile.c
index 916efb505e..81ed8fd284 100644
--- a/compile.c
+++ b/compile.c
@@ -6408,11 +6408,11 @@ compile_case3(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_no
int pat_line = nd_line(pattern);
LABEL *next_pat = NEW_LABEL(pat_line);
ADD_INSN (cond_seq, pat_line, dup);
-
// NOTE: set deconstructed_pos to the current cached value location
// (it's "under" the matchee value, so it's position is 2)
CHECK(iseq_compile_pattern_each(iseq, cond_seq, pattern, l1, next_pat, FALSE, 2));
ADD_LABEL(cond_seq, next_pat);
+ LABEL_UNREMOVABLE(next_pat);
}
else {
COMPILE_ERROR(ERROR_ARGS "unexpected node");
diff --git a/test/ruby/test_pattern_matching.rb b/test/ruby/test_pattern_matching.rb
index 243a4cd2bd..e4c7507ac4 100644
--- a/test/ruby/test_pattern_matching.rb
+++ b/test/ruby/test_pattern_matching.rb
@@ -791,6 +791,16 @@ END
true
end
end
+
+ # https://bugs.ruby-lang.org/issues/17534
+ assert_block do
+ case [0, 1, 2]
+ in x
+ true
+ in [*, 2, *]
+ false
+ end
+ end
end
def test_hash_pattern