зеркало из https://github.com/github/ruby.git
A positional Hash is not keyword arguments [Bug #18632]
This commit is contained in:
Родитель
e660b934b9
Коммит
4fdb10e65e
9
eval.c
9
eval.c
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче