diff options
| author | nagachika <nagachika@ruby-lang.org> | 2024-08-18 18:07:14 +0900 |
|---|---|---|
| committer | nagachika <nagachika@ruby-lang.org> | 2024-08-18 18:07:14 +0900 |
| commit | 21c708ee802e1a59901eccc6448e40e8f72189b8 (patch) | |
| tree | 3aa63f127e7ba40f9e2977b69fad8c46b935d28c | |
| parent | 65fed1c3e439bc47bcf6ec884431a86cb9ebd1dc (diff) | |
merge revision(s) 992596fb7af18a7f472589a607d0eb3fbb03b49a: [Backport #20344]
Fix next inside block argument stack underflow
[Bug #20344]
Fix compile_next adding removable adjust label
| -rw-r--r-- | compile.c | 4 | ||||
| -rw-r--r-- | test/ruby/test_iseq.rb | 21 | ||||
| -rw-r--r-- | version.h | 2 |
3 files changed, 23 insertions, 4 deletions
@@ -2856,8 +2856,7 @@ remove_unreachable_chunk(rb_iseq_t *iseq, LINK_ELEMENT *i) /* do nothing */ } else if (IS_ADJUST(i)) { - LABEL *dest = ((ADJUST *)i)->label; - if (dest && dest->unremovable) return 0; + return 0; } end = i; } while ((i = i->next) != 0); @@ -7658,7 +7657,6 @@ compile_next(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in add_ensure_iseq(ret, iseq, 0); ADD_INSNL(ret, line_node, jump, ISEQ_COMPILE_DATA(iseq)->end_label); ADD_ADJUST_RESTORE(ret, splabel); - splabel->unremovable = FALSE; if (!popped) { ADD_INSN(ret, line_node, putnil); diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb index c1de8c96de..f5147831e4 100644 --- a/test/ruby/test_iseq.rb +++ b/test/ruby/test_iseq.rb @@ -781,4 +781,25 @@ class TestISeq < Test::Unit::TestCase end end; end + + def test_unreachable_next_in_block + bug20344 = '[ruby-core:117210] [Bug #20344]' + assert_nothing_raised(SyntaxError, bug20344) do + compile(<<~RUBY) + proc do + next + + case nil + when "a" + next + when "b" + when "c" + proc {} + end + + next + end + RUBY + end + end end @@ -11,7 +11,7 @@ # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR #define RUBY_VERSION_TEENY 5 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 213 +#define RUBY_PATCHLEVEL 214 #include "ruby/version.h" #include "ruby/internal/abi.h" |
