ruby-changes:64959
From: Nobuyoshi <ko1@a...>
Date: Tue, 19 Jan 2021 17:59:59 +0900 (JST)
Subject: [ruby-changes:64959] eeacdcb9a0 (master): Fixed premature return
https://git.ruby-lang.org/ruby.git/commit/?id=eeacdcb9a0 From eeacdcb9a073c7d8ad703e0dc9faf229a5ebbe3c Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Tue, 19 Jan 2021 16:40:46 +0900 Subject: Fixed premature return After setting ruby2_keywords for bmethod, the rest of arguments had been ignored. [Bug #17558] diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index de367e6..0bdcb79 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -2366,6 +2366,11 @@ class TestKeywordArguments < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L2366 baz(*args) end + define_method(:block_splat) {|*args| } + ruby2_keywords :block_splat, def foo_bar_after_bmethod(*args) + bar(*args) + end + ruby2_keywords def foo_baz2(*args) baz(*args) baz(*args) @@ -2501,6 +2506,7 @@ class TestKeywordArguments < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L2506 assert_equal([1, h1], o.foo(:foo_baz, 1, :a=>1)) assert_equal([[1], h1], o.foo_foo_bar(1, :a=>1)) assert_equal([1, h1], o.foo_foo_baz(1, :a=>1)) + assert_equal([[1], h1], o.foo_bar_after_bmethod(1, :a=>1)) assert_equal([[1], h1], o.foo(:bar, 1, **h1)) assert_equal([1, h1], o.foo(:baz, 1, **h1)) @@ -2516,6 +2522,7 @@ class TestKeywordArguments < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L2522 assert_equal([1, h1], o.foo(:foo_baz, 1, **h1)) assert_equal([[1], h1], o.foo_foo_bar(1, **h1)) assert_equal([1, h1], o.foo_foo_baz(1, **h1)) + assert_equal([[1], h1], o.foo_bar_after_bmethod(1, **h1)) assert_equal([[h1], {}], o.foo(:bar, h1, **{})) assert_equal([h1], o.foo(:baz, h1, **{})) @@ -2531,6 +2538,7 @@ class TestKeywordArguments < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L2538 assert_equal([h1], o.foo(:foo_baz, h1, **{})) assert_equal([[h1], {}], o.foo_foo_bar(h1, **{})) assert_equal([h1], o.foo_foo_baz(h1, **{})) + assert_equal([[h1], {}], o.foo_bar_after_bmethod(h1, **{})) assert_equal([[1, h1], {}], o.foo(:bar, 1, h1)) assert_equal([1, h1], o.foo(:baz, 1, h1)) @@ -2540,6 +2548,7 @@ class TestKeywordArguments < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L2548 assert_equal([1, h1], o.store_foo(:baz, 1, h1)) assert_equal([[1, h1], {}], o.foo_bar(1, h1)) assert_equal([1, h1], o.foo_baz(1, h1)) + assert_equal([[1, h1], {}], o.foo_bar_after_bmethod(1, h1)) assert_equal([[1, h1, 1], {}], o.foo_mod(:bar, 1, :a=>1)) assert_equal([1, h1, 1], o.foo_mod(:baz, 1, :a=>1)) diff --git a/vm_method.c b/vm_method.c index aee5d61..c4eb3dd 100644 --- a/vm_method.c +++ b/vm_method.c @@ -2208,7 +2208,7 @@ rb_mod_ruby2_keywords(int argc, VALUE *argv, VALUE module) https://github.com/ruby/ruby/blob/trunk/vm_method.c#L2208 else { rb_warn("Skipping set of ruby2_keywords flag for %s (method accepts keywords or method does not accept argument splat)", rb_id2name(name)); } - return Qnil; + break; } } /* fallthrough */ -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/