diff options
-rw-r--r-- | compile.c | 8 | ||||
-rw-r--r-- | test/ruby/test_syntax.rb | 9 | ||||
-rw-r--r-- | version.h | 2 |
3 files changed, 13 insertions, 6 deletions
@@ -2742,7 +2742,6 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal 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 * leave * => * leave - * pop * ... * LABEL: * leave @@ -2760,9 +2758,6 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal 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 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 3e77f44efe..ab462bddf4 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -1265,6 +1265,15 @@ eom 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 @@ -1,6 +1,6 @@ #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 |