diff options
| author | Takashi Kokubun <takashikkbn@gmail.com> | 2025-02-13 17:52:03 -0800 |
|---|---|---|
| committer | Takashi Kokubun <takashikkbn@gmail.com> | 2025-02-13 17:52:03 -0800 |
| commit | 68013d43a35a8368caa7b30c501e270333d04b35 (patch) | |
| tree | a45d163b5c911390cda0723f2daa41455a3e4ce3 | |
| parent | 8a86e52fb5fc49367e79f8f49fb451ab74e089bb (diff) | |
merge revision(s) 31905d9e23ec6d1fa2a52f1ef2533f2056e7c9fb: [Backport #21001]
Allow escaping from ensures through next
Fixes [Bug #21001]
| -rw-r--r-- | prism_compile.c | 9 | ||||
| -rw-r--r-- | test/ruby/test_compile_prism.rb | 21 | ||||
| -rw-r--r-- | version.h | 2 |
3 files changed, 22 insertions, 10 deletions
diff --git a/prism_compile.c b/prism_compile.c index a021b4c94f..8bef6ce747 100644 --- a/prism_compile.c +++ b/prism_compile.c @@ -8716,16 +8716,7 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret, const pm_ensure_node_t *cast = (const pm_ensure_node_t *) node; if (cast->statements != NULL) { - LABEL *start = NEW_LABEL(location.line); - LABEL *end = NEW_LABEL(location.line); - PUSH_LABEL(ret, start); - - LABEL *prev_end_label = ISEQ_COMPILE_DATA(iseq)->end_label; - ISEQ_COMPILE_DATA(iseq)->end_label = end; - PM_COMPILE((const pm_node_t *) cast->statements); - ISEQ_COMPILE_DATA(iseq)->end_label = prev_end_label; - PUSH_LABEL(ret, end); } return; diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb index 043d5d8c0e..33a8b17b99 100644 --- a/test/ruby/test_compile_prism.rb +++ b/test/ruby/test_compile_prism.rb @@ -1189,6 +1189,27 @@ a res RUBY + + # Bug #21001 + assert_prism_eval(<<~RUBY) + RUN_ARRAY = [1,2] + + MAP_PROC = Proc.new do |&blk| + block_results = [] + RUN_ARRAY.each do |value| + block_value = blk.call(value) + block_results.push block_value + end + block_results + ensure + next block_results + end + + MAP_PROC.call do |value| + break if value > 1 + next value + end + RUBY end def test_NextNode @@ -11,7 +11,7 @@ # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR #define RUBY_VERSION_TEENY 1 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 4 +#define RUBY_PATCHLEVEL 5 #include "ruby/version.h" #include "ruby/internal/abi.h" |
