Fix wrong unreachable chunk remove when jump destination label is unremovable

This commit is contained in:
tomoya ishida 2024-07-30 15:31:58 +09:00 committed by GitHub
parent 77f8107efa
commit 1870505f47
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
Notes: git 2024-07-30 06:32:16 +00:00
Merged: https://github.com/ruby/ruby/pull/11267

Merged-By: nobu <nobu@ruby-lang.org>
2 changed files with 5 additions and 1 deletions

View File

@ -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]++;
}
}

View File

@ -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:}