diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-11-05 09:28:08 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-11-05 09:28:08 +0000 |
commit | fb9df41221bfe285227537e04cb822b28188501e (patch) | |
tree | f55a0f8a40ed1a17ea6957e59754213d6fc291e1 | |
parent | ac96c3f6c2e500ff6cc8cbceb98363eddb50f890 (diff) |
merge revision(s) 48102: [Backport #10413]
* 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/branches/ruby_2_0_0@48284 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | test/ruby/test_keyword.rb | 15 | ||||
-rw-r--r-- | version.h | 8 | ||||
-rw-r--r-- | vm_insnhelper.c | 4 |
4 files changed, 29 insertions, 5 deletions
@@ -1,3 +1,10 @@ +Wed Nov 5 18:26:49 2014 NAKAMURA Usaku <usa@ruby-lang.org> + + * vm_insnhelper.c (unknown_keyword_error): delete expected keywords + directly from raw table, so that the given block is not called. + derived from r48102 of trunk. + [ruby-core:65837] [Bug #10413] + Mon Oct 27 20:21:05 2014 NAKAMURA Usaku <usa@ruby-lang.org> * lib/rexml/entity.rb: keep the entity size within the limitation. diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index 8a00128605..118e82720f 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -359,4 +359,19 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal([{}, {}], a.new.foo({})) assert_equal([{}, {:bar=>"x"}], a.new.foo({}, bar: "x")) 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 @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.0.0" -#define RUBY_RELEASE_DATE "2014-10-28" -#define RUBY_PATCHLEVEL 595 +#define RUBY_RELEASE_DATE "2014-11-05" +#define RUBY_PATCHLEVEL 596 #define RUBY_RELEASE_YEAR 2014 -#define RUBY_RELEASE_MONTH 10 -#define RUBY_RELEASE_DAY 28 +#define RUBY_RELEASE_MONTH 11 +#define RUBY_RELEASE_DAY 5 #include "ruby/version.h" diff --git a/vm_insnhelper.c b/vm_insnhelper.c index b639dd6f96..9f3a641fbe 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -148,10 +148,12 @@ static void unknown_keyword_error(const rb_iseq_t *iseq, VALUE hash) { VALUE sep = rb_usascii_str_new2(", "), keys; + st_table *tbl = rb_hash_tbl(hash); const char *msg; int i; for (i = 0; i < iseq->arg_keywords; i++) { - rb_hash_delete(hash, ID2SYM(iseq->arg_keyword_table[i])); + st_data_t key = ID2SYM(iseq->arg_keyword_table[i]); + st_delete(tbl, &key, NULL); } keys = rb_funcall(hash, rb_intern("keys"), 0, 0); if (!RB_TYPE_P(keys, T_ARRAY)) rb_raise(rb_eArgError, "unknown keyword"); |