summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--compile.c2
-rw-r--r--test/ruby/test_keyword.rb30
3 files changed, 36 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 67c9ff7..630ddf5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat May 18 16:38:39 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * compile.c (iseq_compile_each): forward anonymous and first keyword
+ rest argument one. [ruby-core:55033] [Bug #8416].
+
Sat May 18 15:49:14 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* vm_core.h (rb_vm_tag): move jmpbuf between tag and prev so ensure to
diff --git a/compile.c b/compile.c
index c079c03..57f5a5f 100644
--- a/compile.c
+++ b/compile.c
@@ -4485,7 +4485,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
}
}
- if (liseq->arg_keyword > 0) {
+ if (liseq->arg_keyword >= 0) {
int local_size = liseq->local_size;
int idx = local_size - liseq->arg_keyword;
argc++;
diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb
index ae56757..7443937 100644
--- a/test/ruby/test_keyword.rb
+++ b/test/ruby/test_keyword.rb
@@ -349,4 +349,34 @@ class TestKeywordArguments < Test::Unit::TestCase
assert_equal([42, {:bar=>"x"}], a.new.foo(42), bug8236)
assert_equal([42, {:bar=>"x"}], b.new.foo(42), bug8236)
end
+
+ def test_zsuper_only_named_kwrest
+ bug8416 = '[ruby-core:55033] [Bug #8416]'
+ base = Class.new do
+ def foo(**h)
+ h
+ end
+ end
+ a = Class.new(base) do
+ def foo(**h)
+ super
+ end
+ end
+ assert_equal({:bar=>"x"}, a.new.foo(bar: "x"), bug8416)
+ end
+
+ def test_zsuper_only_anonymous_kwrest
+ bug8416 = '[ruby-core:55033] [Bug #8416]'
+ base = Class.new do
+ def foo(**h)
+ h
+ end
+ end
+ a = Class.new(base) do
+ def foo(**)
+ super
+ end
+ end
+ assert_equal({:bar=>"x"}, a.new.foo(bar: "x"), bug8416)
+ end
end