mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
class.c: delete expected keywords directly
* class.c (unknown_keyword_error): delete expected keywords directly from raw table, so that the given block is not called. [ruby-core:65837] [Bug #10413] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
052c85da96
commit
67121b5060
3 changed files with 24 additions and 1 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
Thu Oct 23 03:41:51 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* class.c (unknown_keyword_error): delete expected keywords
|
||||||
|
directly from raw table, so that the given block is not called.
|
||||||
|
[ruby-core:65837] [Bug #10413]
|
||||||
|
|
||||||
Thu Oct 23 02:33:01 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Thu Oct 23 02:33:01 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* common.mk (update-unicode): invert dependency to run every times.
|
* common.mk (update-unicode): invert dependency to run every times.
|
||||||
|
|
4
class.c
4
class.c
|
@ -1881,10 +1881,12 @@ NORETURN(static void unknown_keyword_error(VALUE hash, const ID *table, int keyw
|
||||||
static void
|
static void
|
||||||
unknown_keyword_error(VALUE hash, const ID *table, int keywords)
|
unknown_keyword_error(VALUE hash, const ID *table, int keywords)
|
||||||
{
|
{
|
||||||
|
st_table *tbl = rb_hash_tbl_raw(hash);
|
||||||
VALUE keys;
|
VALUE keys;
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < keywords; i++) {
|
for (i = 0; i < keywords; i++) {
|
||||||
rb_hash_delete(hash, ID2SYM(table[i]));
|
st_data_t key = ID2SYM(table[i]);
|
||||||
|
st_delete(tbl, &key, NULL);
|
||||||
}
|
}
|
||||||
keys = rb_funcall(hash, rb_intern("keys"), 0, 0);
|
keys = rb_funcall(hash, rb_intern("keys"), 0, 0);
|
||||||
if (!RB_TYPE_P(keys, T_ARRAY)) rb_raise(rb_eArgError, "unknown keyword");
|
if (!RB_TYPE_P(keys, T_ARRAY)) rb_raise(rb_eArgError, "unknown keyword");
|
||||||
|
|
|
@ -514,4 +514,19 @@ class TestKeywordArguments < Test::Unit::TestCase
|
||||||
assert_nothing_raised(bug) {eval("def a(hoge:); end")}
|
assert_nothing_raised(bug) {eval("def a(hoge:); end")}
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_unknown_keyword_with_block
|
||||||
|
bug10413 = '[ruby-core:65837] [Bug #10413]'
|
||||||
|
class << (o = Object.new)
|
||||||
|
def bar(k2: 'v2')
|
||||||
|
end
|
||||||
|
|
||||||
|
def foo
|
||||||
|
bar(k1: 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
assert_raise_with_message(ArgumentError, /unknown keyword: k1/, bug10413) {
|
||||||
|
o.foo {raise "unreachable"}
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue