aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-01-13 21:15:13 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-01-13 21:16:00 +0900
commit0036648a420f945624898568bb82bc5f83195d12 (patch)
tree1ddad9a8be124fb58f74b614caddd20564a1b584 /test
parente9b93d67baf8a6add548b7e5c702665100e4b3c9 (diff)
downloadruby-0036648a420f945624898568bb82bc5f83195d12.tar.gz
Capture to reserved name variables if already defined [Bug #17533]
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_regexp.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb
index 194b8c355d..495c9de919 100644
--- a/test/ruby/test_regexp.rb
+++ b/test/ruby/test_regexp.rb
@@ -229,6 +229,17 @@ class TestRegexp < Test::Unit::TestCase
def test_assign_named_capture_to_reserved_word
/(?<nil>.)/ =~ "a"
assert_not_include(local_variables, :nil, "[ruby-dev:32675]")
+
+ def (obj = Object.new).test(s, nil: :ng)
+ /(?<nil>.)/ =~ s
+ binding.local_variable_get(:nil)
+ end
+ assert_equal("b", obj.test("b"))
+
+ tap do |nil: :ng|
+ /(?<nil>.)/ =~ "c"
+ assert_equal("c", binding.local_variable_get(:nil))
+ end
end
def test_assign_named_capture_to_const