Skip to content

Commit d83b563

Browse files
committed
merge revision(s) 992596f: [Backport #20344]
Fix next inside block argument stack underflow [Bug #20344] Fix compile_next adding removable adjust label
1 parent b210c86 commit d83b563

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

compile.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2991,8 +2991,7 @@ remove_unreachable_chunk(rb_iseq_t *iseq, LINK_ELEMENT *i)
29912991
/* do nothing */
29922992
}
29932993
else if (IS_ADJUST(i)) {
2994-
LABEL *dest = ((ADJUST *)i)->label;
2995-
if (dest && dest->unremovable) return 0;
2994+
return 0;
29962995
}
29972996
end = i;
29982997
} while ((i = i->next) != 0);
@@ -7892,7 +7891,6 @@ compile_next(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in
78927891
add_ensure_iseq(ret, iseq, 0);
78937892
ADD_INSNL(ret, line_node, jump, ISEQ_COMPILE_DATA(iseq)->end_label);
78947893
ADD_ADJUST_RESTORE(ret, splabel);
7895-
splabel->unremovable = FALSE;
78967894

78977895
if (!popped) {
78987896
ADD_INSN(ret, line_node, putnil);

test/ruby/test_iseq.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,27 @@ def test_unreachable_pattern_matching_in_if_condition
795795
end;
796796
end
797797

798+
def test_unreachable_next_in_block
799+
bug20344 = '[ruby-core:117210] [Bug #20344]'
800+
assert_nothing_raised(SyntaxError, bug20344) do
801+
compile(<<~RUBY)
802+
proc do
803+
next
804+
805+
case nil
806+
when "a"
807+
next
808+
when "b"
809+
when "c"
810+
proc {}
811+
end
812+
813+
next
814+
end
815+
RUBY
816+
end
817+
end
818+
798819
def test_loading_kwargs_memory_leak
799820
assert_no_memory_leak([], "#{<<~"begin;"}", "#{<<~'end;'}", rss: true)
800821
a = RubyVM::InstructionSequence.compile("foo(bar: :baz)").to_binary

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
1212
#define RUBY_VERSION_TEENY 4
1313
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
14-
#define RUBY_PATCHLEVEL 97
14+
#define RUBY_PATCHLEVEL 98
1515

1616
#include "ruby/version.h"
1717
#include "ruby/internal/abi.h"

0 commit comments

Comments
 (0)