From fd734d4992f68fb6d2e97e65cf97f6629e13a108 Mon Sep 17 00:00:00 2001 From: usa Date: Sun, 4 Apr 2021 23:43:53 +0000 Subject: merge revision(s) 0036648a420f945624898568bb82bc5f83195d12: [Backport #17533] Capture to reserved name variables if already defined [Bug #17533] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67927 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_regexp.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test') diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index 38147c7446..038c1c830f 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -218,6 +218,17 @@ class TestRegexp < Test::Unit::TestCase def test_assign_named_capture_to_reserved_word /(?.)/ =~ "a" assert_not_include(local_variables, :nil, "[ruby-dev:32675]") + + def (obj = Object.new).test(s, nil: :ng) + /(?.)/ =~ s + binding.local_variable_get(:nil) + end + assert_equal("b", obj.test("b")) + + tap do |nil: :ng| + /(?.)/ =~ "c" + assert_equal("c", binding.local_variable_get(:nil)) + end end def test_assign_named_capture_to_const -- cgit v1.2.3