diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-07-03 18:50:55 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-07-03 18:50:55 +0000 |
commit | b94b3260747470c2577c513974270d200a30564b (patch) | |
tree | 911b09658b57749e3f75f3995d2b05a6a07c6d20 | |
parent | 9a3e7b691354e818f3619a3cec855ae6aa11e7cb (diff) |
merge revision(s) 50850: [Backport #11254]
vm.c: break from orphan block
* vm.c (rb_vm_search_cf_from_ep): break from orphan block is
possible condition, but not [BUG].
[ruby-core:69548] [Bug #11254]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@51129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | test/ruby/test_enum.rb | 21 | ||||
-rw-r--r-- | version.h | 6 | ||||
-rw-r--r-- | vm.c | 8 |
3 files changed, 29 insertions, 6 deletions
diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb index 532d1b965a..53e24fc346 100644 --- a/test/ruby/test_enum.rb +++ b/test/ruby/test_enum.rb @@ -55,7 +55,8 @@ class TestEnumerable < Test::Unit::TestCase bug5801 = '[ruby-dev:45041]' @empty.grep(//) - assert_nothing_raised(bug5801) {100.times {@empty.block.call}} + block = @empty.block + assert_nothing_raised(bug5801) {100.times {block.call}} a = [] lambda = ->(x, i) {a << [x, i]} @@ -173,6 +174,21 @@ class TestEnumerable < Test::Unit::TestCase assert_equal(1, @obj.first) assert_equal([1, 2, 3], @obj.first(3)) assert_nil(@empty.first) + + bug5801 = '[ruby-dev:45041]' + assert_in_out_err([], <<-'end;', [], /unexpected break/) + empty = Object.new + class << empty + attr_reader :block + include Enumerable + def each(&block) + @block = block + self + end + end + empty.first + empty.block.call + end; end def test_sort @@ -396,7 +412,8 @@ class TestEnumerable < Test::Unit::TestCase bug5801 = '[ruby-dev:45040]' @empty.take_while {true} - assert_nothing_raised(bug5801) {100.times {@empty.block.call}} + block = @empty.block + assert_nothing_raised(bug5801) {100.times {block.call}} end def test_drop @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.2.3" -#define RUBY_RELEASE_DATE "2015-07-01" -#define RUBY_PATCHLEVEL 139 +#define RUBY_RELEASE_DATE "2015-07-04" +#define RUBY_PATCHLEVEL 140 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 1 +#define RUBY_RELEASE_DAY 4 #include "ruby/version.h" @@ -44,7 +44,7 @@ rb_vm_search_cf_from_ep(const rb_thread_t * const th, rb_control_frame_t *cfp, c cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); } - rb_bug("rb_vm_search_cf_from_ep: no corresponding cfp"); + return NULL; } } @@ -1146,6 +1146,12 @@ vm_iter_break(rb_thread_t *th, VALUE val) VALUE *ep = VM_CF_PREV_EP(cfp); rb_control_frame_t *target_cfp = rb_vm_search_cf_from_ep(th, cfp, ep); +#if 0 /* raise LocalJumpError */ + if (!target_cfp) { + rb_vm_localjump_error("unexpected break", val, TAG_BREAK); + } +#endif + th->state = TAG_BREAK; th->errinfo = (VALUE)NEW_THROW_OBJECT(val, (VALUE)target_cfp, TAG_BREAK); TH_JUMP_TAG(th, TAG_BREAK); |