From 8cad54a696cba1f2585cdca8d0f5e210d19e2662 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 17 Apr 2017 02:41:00 +0000 Subject: 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 --- test/ruby/test_exception.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test') diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index 37b5f7068c..1179c26c51 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -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 -- cgit v1.2.3