summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2021-02-20 17:56:14 +0900
committernagachika <nagachika@ruby-lang.org>2021-02-20 17:56:14 +0900
commit3d39ad217866138de1d3597440ef6358690b3435 (patch)
tree0d0a66f30a45df26d1331f1c19eb9240677e33e8 /test/ruby
parent14823c2d7c20dba288025749b4d55c02d8729871 (diff)
merge revision(s) 0036648a420f945624898568bb82bc5f83195d12: [Backport #17533]
Capture to reserved name variables if already defined [Bug #17533] --- parse.y | 5 +++-- test/ruby/test_regexp.rb | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-)
Diffstat (limited to 'test/ruby')
-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 b469d643f2..dc203fa82a 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
/(?<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