mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Issue a warning if invalid kw_splat is passed to *_kw function
This should only happen if the API is misused. It's much better to warn here and fix the problem, versus to try to debug TypeErrors or segfaults later.
This commit is contained in:
parent
395e5f510c
commit
1edcfd6107
1 changed files with 6 additions and 0 deletions
|
@ -255,6 +255,12 @@ add_empty_keyword(int *argc, const VALUE **argv, int *kw_splat)
|
|||
*kw_splat = rb_keyword_given_p();
|
||||
}
|
||||
}
|
||||
|
||||
if (*kw_splat && *argc > 0 && !RB_TYPE_P((*argv)[(*argc)-1], T_HASH)) {
|
||||
rb_warn("Keyword flag passed calling internal method, but last entry is not a hash, unsetting keyword flag");
|
||||
*kw_splat = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue