From 864bb8680cee48a2bed85703dc2e4070728362d4 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 13 Sep 2023 22:09:22 +0900 Subject: [Bug #19877] Named captures should take place from regexps in block --- test/ruby/test_parse.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index 5209a4839f..0f71e11f7e 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -970,6 +970,20 @@ x = __ENCODING__ assert_warning('') {eval("#{a} = 1; /(?<#{a}>)/ =~ ''")} end + def test_named_capture_in_block + [ + '(/(?.*)/)', + '(;/(?.*)/)', + '(%s();/(?.*)/)', + '(%w();/(?.*)/)', + '(1; (2; 3; (4; /(?.*)/)))', + '(1+1; /(?.*)/)', + ].each do |code| + token = Random.bytes(4).unpack1("H*") + assert_equal(token, eval("#{code} =~ #{token.dump}; a")) + end + end + def test_rescue_in_command_assignment bug = '[ruby-core:75621] [Bug #12402]' all_assertions(bug) do |a| -- cgit v1.2.3