From fb9df41221bfe285227537e04cb822b28188501e Mon Sep 17 00:00:00 2001 From: usa Date: Wed, 5 Nov 2014 09:28:08 +0000 Subject: 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 --- ChangeLog | 7 +++++++ test/ruby/test_keyword.rb | 15 +++++++++++++++ version.h | 8 ++++---- vm_insnhelper.c | 4 +++- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index b0a39875df..935912e530 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Nov 5 18:26:49 2014 NAKAMURA Usaku + + * 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 * 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 diff --git a/version.h b/version.h index b6d05cb20b..a0e3aae8c5 100644 --- a/version.h +++ b/version.h @@ -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"); -- cgit v1.2.3