eval.c: copy before cause setup

* eval.c (setup_exception): copy frozen exception before setting
  up a cause not only a backtrace.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58381 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-04-17 02:41:00 +00:00
parent e601e77590
commit 61ea519dc0
2 changed files with 22 additions and 11 deletions

View file

@ -799,6 +799,13 @@ end.join
assert_nil(orig_error.cause, bug13043)
end
def test_cause_with_frozen_exception
exc = ArgumentError.new("foo").freeze
assert_raise_with_message(ArgumentError, exc.message) {
raise exc, cause: RuntimeError.new("bar")
}
end
def test_anonymous_message
assert_in_out_err([], "raise Class.new(RuntimeError), 'foo'", [], /foo\n/)
end