Skip to content

Commit fb9df41

Browse files
committed
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
1 parent ac96c3f commit fb9df41

File tree

4 files changed

+29
-5
lines changed

4 files changed

+29
-5
lines changed

ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
Wed Nov 5 18:26:49 2014 NAKAMURA Usaku <usa@ruby-lang.org>
2+
3+
* vm_insnhelper.c (unknown_keyword_error): delete expected keywords
4+
directly from raw table, so that the given block is not called.
5+
derived from r48102 of trunk.
6+
[ruby-core:65837] [Bug #10413]
7+
18
Mon Oct 27 20:21:05 2014 NAKAMURA Usaku <usa@ruby-lang.org>
29

310
* lib/rexml/entity.rb: keep the entity size within the limitation.

test/ruby/test_keyword.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,4 +359,19 @@ def foo(x, **h)
359359
assert_equal([{}, {}], a.new.foo({}))
360360
assert_equal([{}, {:bar=>"x"}], a.new.foo({}, bar: "x"))
361361
end
362+
363+
def test_unknown_keyword_with_block
364+
bug10413 = '[ruby-core:65837] [Bug #10413]'
365+
class << (o = Object.new)
366+
def bar(k2: 'v2')
367+
end
368+
369+
def foo
370+
bar(k1: 1)
371+
end
372+
end
373+
assert_raise_with_message(ArgumentError, /unknown keyword: k1/, bug10413) {
374+
o.foo {raise "unreachable"}
375+
}
376+
end
362377
end

version.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#define RUBY_VERSION "2.0.0"
2-
#define RUBY_RELEASE_DATE "2014-10-28"
3-
#define RUBY_PATCHLEVEL 595
2+
#define RUBY_RELEASE_DATE "2014-11-05"
3+
#define RUBY_PATCHLEVEL 596
44

55
#define RUBY_RELEASE_YEAR 2014
6-
#define RUBY_RELEASE_MONTH 10
7-
#define RUBY_RELEASE_DAY 28
6+
#define RUBY_RELEASE_MONTH 11
7+
#define RUBY_RELEASE_DAY 5
88

99
#include "ruby/version.h"
1010

vm_insnhelper.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,12 @@ static void
148148
unknown_keyword_error(const rb_iseq_t *iseq, VALUE hash)
149149
{
150150
VALUE sep = rb_usascii_str_new2(", "), keys;
151+
st_table *tbl = rb_hash_tbl(hash);
151152
const char *msg;
152153
int i;
153154
for (i = 0; i < iseq->arg_keywords; i++) {
154-
rb_hash_delete(hash, ID2SYM(iseq->arg_keyword_table[i]));
155+
st_data_t key = ID2SYM(iseq->arg_keyword_table[i]);
156+
st_delete(tbl, &key, NULL);
155157
}
156158
keys = rb_funcall(hash, rb_intern("keys"), 0, 0);
157159
if (!RB_TYPE_P(keys, T_ARRAY)) rb_raise(rb_eArgError, "unknown keyword");

0 commit comments

Comments
 (0)