mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Check Module#ruby2_keywords arity
It is considered a mistake, because calling this method with no arguments has no effect.
This commit is contained in:
parent
076f24c227
commit
34bc15c86b
Notes:
git
2020-01-02 10:56:09 +09:00
2 changed files with 7 additions and 0 deletions
|
@ -2724,6 +2724,12 @@ class TestKeywordArguments < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_ruby2_keywords
|
def test_ruby2_keywords
|
||||||
|
assert_raise(ArgumentError) do
|
||||||
|
Class.new do
|
||||||
|
ruby2_keywords
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
c = Class.new do
|
c = Class.new do
|
||||||
ruby2_keywords def foo(meth, *args)
|
ruby2_keywords def foo(meth, *args)
|
||||||
send(meth, *args)
|
send(meth, *args)
|
||||||
|
|
|
@ -1811,6 +1811,7 @@ rb_mod_ruby2_keywords(int argc, VALUE *argv, VALUE module)
|
||||||
int i;
|
int i;
|
||||||
VALUE origin_class = RCLASS_ORIGIN(module);
|
VALUE origin_class = RCLASS_ORIGIN(module);
|
||||||
|
|
||||||
|
rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS);
|
||||||
rb_check_frozen(module);
|
rb_check_frozen(module);
|
||||||
|
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue