diff options
-rw-r--r-- | eval.c | 9 | ||||
-rw-r--r-- | test/ruby/test_exception.rb | 1 |
2 files changed, 6 insertions, 4 deletions
@@ -695,17 +695,18 @@ rb_interrupt(void) enum {raise_opt_cause, raise_max_opt}; /*< \private */ static int -extract_raise_opts(int argc, const VALUE *argv, VALUE *opts) +extract_raise_opts(int argc, VALUE *argv, VALUE *opts) { int i; if (argc > 0) { - VALUE opt = argv[argc-1]; - if (RB_TYPE_P(opt, T_HASH)) { + VALUE opt; + argc = rb_scan_args(argc, argv, "*:", NULL, &opt); + if (!NIL_P(opt)) { if (!RHASH_EMPTY_P(opt)) { ID keywords[1]; CONST_ID(keywords[0], "cause"); rb_get_kwargs(opt, keywords, 0, -1-raise_max_opt, opts); - if (RHASH_EMPTY_P(opt)) --argc; + if (!RHASH_EMPTY_P(opt)) argv[argc++] = opt; return argc; } } diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index ffa7aa6703..0b05ff7c51 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -807,6 +807,7 @@ end.join cause = ArgumentError.new("foobar") e = assert_raise(RuntimeError) {raise msg, cause: cause} assert_same(cause, e.cause) + assert_raise(TypeError) {raise msg, {cause: cause}} end def test_cause_with_no_arguments |