1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

eval_error.c (show_cause): check if cause is an Exception or not

Fixes [Bug #15447]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66475 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mame 2018-12-21 11:44:21 +00:00
parent 09b3d38c72
commit 010a742cb6
2 changed files with 10 additions and 1 deletions

View file

@ -226,7 +226,7 @@ static void
show_cause(VALUE errinfo, VALUE str, VALUE highlight, VALUE reverse)
{
VALUE cause = rb_attr_get(errinfo, id_cause);
if (!NIL_P(cause)) {
if (!NIL_P(cause) && rb_obj_is_kind_of(cause, rb_eException)) {
volatile VALUE eclass = CLASS_OF(cause);
VALUE errat = rb_get_backtrace(cause);
VALUE emesg = rb_get_message(cause);

View file

@ -1341,6 +1341,15 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
assert_in_out_err([], code, [], /Bug14566/, success: false, timeout: 2)
end
def test_non_exception_cause
puts "foo"
code = "#{<<~"begin;"}\n#{<<~'end;'}"
begin;
raise "foo", cause: 1
end;
assert_in_out_err([], code, [], /foo/, success: false, timeout: 2)
end
def test_super_in_method_missing
assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
begin;