Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* eval.c (rb_ensure): preserve errinfo accross ensure proc before JUMP_TAG(). [ruby-core:52022] [Bug #7802] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
- Loading branch information
Showing
4 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include <ruby.h> | ||
|
||
static VALUE | ||
begin(VALUE object) | ||
{ | ||
return rb_funcall(object, rb_intern("try_method"), 0); | ||
} | ||
|
||
static VALUE | ||
ensure(VALUE object) | ||
{ | ||
return rb_funcall(object, rb_intern("ensured_method"), 0); | ||
} | ||
|
||
static VALUE | ||
ensured(VALUE module, VALUE object) | ||
{ | ||
return rb_ensure(begin, object, ensure, object); | ||
} | ||
|
||
void | ||
Init_ensured(VALUE klass) | ||
{ | ||
rb_define_module_function(klass, "ensured", ensured, 1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require 'test/unit' | ||
require_relative '../../ruby/envutil' | ||
|
||
module Bug | ||
class Bug7802 < RuntimeError | ||
end | ||
|
||
class TestException < Test::Unit::TestCase | ||
def test_ensured | ||
assert_separately([], <<-'end;') # do | ||
require '-test-/exception' | ||
module Bug | ||
class Bug7802 < RuntimeError | ||
def try_method | ||
raise self | ||
end | ||
def ensured_method | ||
[1].detect {|i| true} | ||
end | ||
end | ||
end | ||
assert_raise(Bug::Bug7802, '[ruby-core:52022] [Bug #7802]') { | ||
Bug::Exception.ensured(Bug::Bug7802.new) | ||
} | ||
end; | ||
end | ||
end | ||
end |