ruby-changes:65769
From: usa <ko1@a...>
Date: Mon, 5 Apr 2021 08:37:04 +0900 (JST)
Subject: [ruby-changes:65769] 8bfee86135 (ruby_2_6): merge revision(s) ce7a053475cbebfb2f3e5ed6614e0ba631541917,1cbb1f1720127b0b34b38c77e27b51b182008699: [Backport #16695]
https://git.ruby-lang.org/ruby.git/commit/?id=8bfee86135 From 8bfee861356c8402f11e6979bf57e25c18dd2a12 Mon Sep 17 00:00:00 2001 From: usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> Date: Sun, 4 Apr 2021 23:36:51 +0000 Subject: merge revision(s) ce7a053475cbebfb2f3e5ed6614e0ba631541917,1cbb1f1720127b0b34b38c77e27b51b182008699: [Backport #16695] Adjust sp for `x = false; y = (return until x unless x)` [Bug #16695] test/ruby/test_syntax.rb: avoid "warning: assigned but unused variable" git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- compile.c | 8 +++----- test/ruby/test_syntax.rb | 9 +++++++++ version.h | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/compile.c b/compile.c index fea789e..f5939ef 100644 --- a/compile.c +++ b/compile.c @@ -2742,7 +2742,6 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal https://github.com/ruby/ruby/blob/trunk/compile.c#L2742 goto again; } else if (IS_INSN_ID(diobj, leave)) { - INSN *pop; /* * jump LABEL * ... @@ -2750,7 +2749,6 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal https://github.com/ruby/ruby/blob/trunk/compile.c#L2749 * leave * => * leave - * pop * ... * LABEL: * leave @@ -2760,9 +2758,6 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal https://github.com/ruby/ruby/blob/trunk/compile.c#L2758 iobj->insn_id = BIN(leave); iobj->operand_size = 0; iobj->insn_info = diobj->insn_info; - /* adjust stack depth */ - pop = new_insn_body(iseq, diobj->insn_info.line_no, BIN(pop), 0); - ELEM_INSERT_NEXT(&iobj->link, &pop->link); goto again; } else if (IS_INSN(iobj->link.prev) && @@ -5059,6 +5054,9 @@ compile_if(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int https://github.com/ruby/ruby/blob/trunk/compile.c#L5054 branches); end_label = NEW_LABEL(line); ADD_INSNL(then_seq, line, jump, end_label); + if (!popped) { + ADD_INSN(then_seq, line, pop); + } } ADD_SEQ(ret, then_seq); } diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 3e77f44..ab462bd 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -1265,6 +1265,15 @@ eom https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L1265 assert_nil obj.test end + def test_assignment_return_in_loop + obj = Object.new + def obj.test + x = nil + _y = (return until x unless x) + end + assert_nil obj.test, "[Bug #16695]" + end + def test_method_call_location line = __LINE__+5 e = assert_raise(NoMethodError) do diff --git a/version.h b/version.h index 78d1fa8..64b9bbc 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L1 #define RUBY_VERSION "2.6.7" #define RUBY_RELEASE_DATE "2021-04-05" -#define RUBY_PATCHLEVEL 184 +#define RUBY_PATCHLEVEL 185 #define RUBY_RELEASE_YEAR 2021 #define RUBY_RELEASE_MONTH 4 -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/