From 1870505f478cc75993b296b7144a45137ace6937 Mon Sep 17 00:00:00 2001 From: tomoya ishida Date: Tue, 30 Jul 2024 15:31:58 +0900 Subject: [PATCH] Fix wrong unreachable chunk remove when jump destination label is unremovable --- compile.c | 1 - test/ruby/test_iseq.rb | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/compile.c b/compile.c index c352ddc501..dfeb7ed284 100644 --- a/compile.c +++ b/compile.c @@ -3054,7 +3054,6 @@ remove_unreachable_chunk(rb_iseq_t *iseq, LINK_ELEMENT *i) break; } else if ((lab = find_destination((INSN *)i)) != 0) { - if (lab->unremovable) break; unref_counts[lab->label_no]++; } } diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb index c946d588c1..9429d8bc21 100644 --- a/test/ruby/test_iseq.rb +++ b/test/ruby/test_iseq.rb @@ -813,6 +813,11 @@ class TestISeq < Test::Unit::TestCase end def test_unreachable_pattern_matching + assert_in_out_err([], "true or 1 in 1") + assert_in_out_err([], "true or (case 1; in 1; 1; in 2; 2; end)") + end + + def test_unreachable_pattern_matching_in_if_condition assert_in_out_err([], "#{<<~"begin;"}\n#{<<~'end;'}", %w[1]) begin; if true or {a: 0} in {a:}