summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-10 04:53:58 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-10 04:53:58 +0000
commit1069d3f18bb3017ba770cc5ac68e4513439e357c (patch)
tree12a905c7e67190d5531a702619ad82961f2ccfe9
parenta1afdedf94350c89007df2f65d79be6fc7b835e3 (diff)
merge revision(s) 59708: [Backport #13844]
compile.c: ensure after toplevel return * compile.c (iseq_compile_each0): toplevel returns should fire ensures. [ruby-core:82492] [Bug #13844] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@59812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--compile.c4
-rw-r--r--test/ruby/test_syntax.rb2
-rw-r--r--version.h2
3 files changed, 4 insertions, 4 deletions
diff --git a/compile.c b/compile.c
index 0883cea78b..44cb8025e8 100644
--- a/compile.c
+++ b/compile.c
@@ -5497,7 +5497,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int poppe
const rb_iseq_t *parent_iseq = is->body->parent_iseq;
enum iseq_type parent_type;
- if (type == ISEQ_TYPE_TOP || type == ISEQ_TYPE_MAIN) {
+ if (type == ISEQ_TYPE_TOP) {
LABEL *splabel = NEW_LABEL(line);
ADD_LABEL(ret, splabel);
ADD_ADJUST(ret, line, 0);
@@ -5505,7 +5505,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int poppe
ADD_INSN(ret, line, leave);
ADD_ADJUST_RESTORE(ret, splabel);
}
- else if ((type == ISEQ_TYPE_RESCUE || type == ISEQ_TYPE_ENSURE) &&
+ else if ((type == ISEQ_TYPE_RESCUE || type == ISEQ_TYPE_ENSURE || type == ISEQ_TYPE_MAIN) &&
parent_iseq &&
((parent_type = parent_iseq->body->type) == ISEQ_TYPE_TOP ||
parent_type == ISEQ_TYPE_MAIN)) {
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index 42866630ad..16515bf705 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -976,7 +976,7 @@ eom
begin;
return; raise
begin return; rescue SystemExit; exit false; end
- begin return; ensure exit false; end
+ begin return; ensure puts "ensured"; end #=> ensured
begin ensure return; end
begin raise; ensure; return; end
begin raise; rescue; return; end
diff --git a/version.h b/version.h
index 21cca02951..7f2448e1ed 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.4.2"
#define RUBY_RELEASE_DATE "2017-09-10"
-#define RUBY_PATCHLEVEL 188
+#define RUBY_PATCHLEVEL 189
#define RUBY_RELEASE_YEAR 2017
#define RUBY_RELEASE_MONTH 9