summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-06 01:31:53 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-06 01:31:53 +0000
commitb4f61ad610536eb8102c31b882dda44967ecd5a9 (patch)
tree2979c68c4428ddebfabc8c5cf656bfe35945ae6e /test
parente27a538eab6a186be4d92147fd51d23eb4503abd (diff)
vm_core.h: fix symbols leak
* vm_core.h (rb_call_info_kw_arg_struct): make keywords a symbols list to get rid of inadvertent creation by variable keyword arguments. [ruby-core:68031] [Bug #10831] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/-ext-/symbol/test_inadvertent_creation.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/-ext-/symbol/test_inadvertent_creation.rb b/test/-ext-/symbol/test_inadvertent_creation.rb
index 9262fc3..4e7a85f 100644
--- a/test/-ext-/symbol/test_inadvertent_creation.rb
+++ b/test/-ext-/symbol/test_inadvertent_creation.rb
@@ -426,5 +426,26 @@ module Test_Symbol
x.method(:send).call(name.to_sym)
end
end
+
+ def test_kwarg_symbol_leak_no_rest
+ foo = -> (arg: 42) {}
+ assert_no_immortal_symbol_created("kwarg no rest") do |name|
+ assert_raise(ArgumentError) { foo.call(name.to_sym => 42) }
+ end
+ end
+
+ def test_kwarg_symbol_leak_with_rest
+ foo = -> (arg: 2, **options) {}
+ assert_no_immortal_symbol_created("kwarg with rest") do |name|
+ foo.call(name.to_sym => 42)
+ end
+ end
+
+ def test_kwarg_symbol_leak_just_rest
+ foo = -> (**options) {}
+ assert_no_immortal_symbol_created("kwarg just rest") do |name|
+ foo.call(name.to_sym => 42)
+ end
+ end
end
end