3 $|=1; # outherwise things get mixed up in output
8 set_up_inc( qw '../lib ../ext/re' );
9 eval 'require Config'; # assume defaults if this fails
12 skip_all_without_unicode_tables();
15 use open qw(:utf8 :std);
17 # Show that it works when all warnings are enabled upon invocation. This file
18 # includes tests that the default warnings are enabled by default, and the
19 # non-default ones aren't.
21 BEGIN { ${^WARNING_BITS} = undef } # Kludge to restore default warnings
23 # Kind of a kludge to mark warnings to be expected only if we are testing
24 # under "use re 'strict'"
25 my $only_strict_marker = ':expected_only_under_strict';
27 ## If the markers used are changed (search for "MARKER1" in regcomp.c),
28 ## update only these two regexs, and leave the {#} in the @death/@warning
29 ## arrays below. The {#} is a meta-marker -- it marks where the marker should
32 sub fixup_expect ($$) {
34 # Fixes up the expected results by inserting the boiler plate text.
35 # Returns empty string if that is what is expected. Otherwise, handles
36 # either a scalar, turning it into a single element array; or a ref to an
37 # array, adjusting each element. If called in array context, returns an
38 # array, otherwise the join of all elements.
40 # The string $only_strict_marker will be removed from any expect line it
41 # begins, and if $strict is not true, that expect line will be removed
42 # from the output (hence won't be expected)
44 my ($expect_ref, $strict) = @_;
45 return "" if $expect_ref eq "";
48 if (ref $expect_ref) {
49 @expect = @$expect_ref;
52 @expect = $expect_ref;
56 foreach my $element (@expect) {
57 $element =~ s/\{\#\}/in regex; marked by <-- HERE in/;
58 $element =~ s/\{\#\}/ <-- HERE /;
60 next if $element =~ s/ ^ $only_strict_marker \s* //x && ! $strict;
61 push @new_expect, $element;
63 return wantarray ? @new_expect : join "", @new_expect;
68 $element =~ s/ at .* line \d+\.?\n$//;
69 $element =~ s/in regex; marked by <-- HERE in/{#}/;
70 $element =~ s/ <-- HERE /{#}/;
74 ## Because we don't "use utf8" in this file, we need to do some extra legwork
75 ## for the utf8 tests: Prepend 'use utf8' to the pattern, and mark the strings
76 ## to check against as UTF-8, but for this all to work properly, the character
77 ## 'ネ' (U+30CD) is required in each pattern somewhere as a marker.
79 ## This also creates a second variant of the tests to check if the
80 ## latin1 error messages are working correctly. Because we don't 'use utf8',
81 ## we can't tell if something is UTF-8 or Latin1, so you need the suffix
82 ## '; no latin1' to not have the second variant.
84 my $utf8 = "\x{30cd}";
89 for (my $i = 0; $i < @_; $i += 2) {
92 my $l1_pat = $pat =~ s/$utf8/$l1/gr;
94 $pat = "use utf8; $pat";
97 $l1_msg = [ map { s/$utf8/$l1/gr } @$msg ];
98 @$msg = map { my $c = $_; utf8::decode($c); $c } @$msg;
101 $l1_msg = $msg =~ s/$utf8/$l1/gr;
104 push @ret, $pat => $msg;
106 push @ret, $l1_pat => $l1_msg unless $l1_pat =~ /#no latin1/;
111 my $inf_m1 = ($Config::Config{reg_infty} || ((1<<31)-1)) - 1;
112 my $inf_p1 = $inf_m1 + 2;
114 my $B_hex = sprintf("\\x%02X", ord "B");
115 my $low_mixed_alpha = ('A' lt 'a') ? 'A' : 'a';
116 my $high_mixed_alpha = ('A' lt 'a') ? 'a' : 'A';
117 my $low_mixed_digit = ('A' lt '0') ? 'A' : '0';
118 my $high_mixed_digit = ('A' lt '0') ? '0' : 'A';
120 my $colon_hex = sprintf "%02X", ord(":");
121 my $tab_hex = sprintf "%02X", ord("\t");
123 # Key-value pairs of strings eval'd as patterns => warn/error messages that
124 # they should generate. In some cases, the value is an array of multiple
125 # messages. Some groups have the message(s) be default on; others, default
126 # off. This can be overridden on an individual key basis by preceding the
127 # pattern string with either 'default_on' or 'default_off'
129 # The first set are those that should be fatal errors.
131 my $bug133423 = "(?[(?^:(?[\\\x00]))\\]\x00|2[^^]\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80])R.\\670";
135 '/[[=foo=]]/' => 'POSIX syntax [= =] is reserved for future extensions {#} m/[[=foo=]{#}]/',
137 '/(?<= .*)/' => 'Lookbehind longer than 255 not implemented in regex m/(?<= .*)/',
139 '/(?<= a+)/' => 'Lookbehind longer than 255 not implemented in regex m/(?<= a+)/',
140 '/(?<= a{255})/' => 'Lookbehind longer than 255 not implemented in regex m/(?<= a{255})/',
141 '/(?<= a{0,255})/' => 'Lookbehind longer than 255 not implemented in regex m/(?<= a{0,255})/',
142 '/(?<= a{200}b{55})/' => 'Lookbehind longer than 255 not implemented in regex m/(?<= a{200}b{55})/',
144 '/(?<= x{1000})/' => 'Lookbehind longer than 255 not implemented in regex m/(?<= x{1000})/',
145 '/(?<= (?&x))(?<x>x+)/' => 'Lookbehind longer than 255 not implemented in regex m/(?<= (?&x))(?<x>x+)/',
147 '/(?@)/' => 'Sequence (?@...) not implemented {#} m/(?@{#})/',
149 '/(?{ 1/' => 'Missing right curly or square bracket',
151 '/(?(1x))/' => 'Switch condition not recognized {#} m/(?(1x{#}))/',
152 '/(?(1x(?#)))/'=> 'Switch condition not recognized {#} m/(?(1x{#}(?#)))/',
154 '/(?(1)/' => 'Switch (?(condition)... not terminated {#} m/(?(1){#}/',
155 '/(?(1)x/' => 'Switch (?(condition)... not terminated {#} m/(?(1)x{#}/',
156 '/(?(1)x|y/' => 'Switch (?(condition)... not terminated {#} m/(?(1)x|y{#}/',
157 '/(?(1)x|y|z)/' => 'Switch (?(condition)... contains too many branches {#} m/(?(1)x|y|{#}z)/',
159 '/(?(x)y|x)/' => 'Unknown switch condition (?(...)) {#} m/(?(x{#})y|x)/',
160 '/(?(??{}))/' => 'Unknown switch condition (?(...)) {#} m/(?(?{#}?{}))/',
161 '/(?(?[]))/' => 'Unknown switch condition (?(...)) {#} m/(?(?{#}[]))/',
163 '/(?/' => 'Sequence (? incomplete {#} m/(?{#}/',
165 '/(?;x/' => 'Sequence (?;...) not recognized {#} m/(?;{#}x/',
166 '/(?<;x/' => 'Group name must start with a non-digit word character {#} m/(?<;{#}x/',
167 '/(?\ix/' => 'Sequence (?\...) not recognized {#} m/(?\{#}ix/',
168 '/(?\mx/' => 'Sequence (?\...) not recognized {#} m/(?\{#}mx/',
169 '/(?\:x/' => 'Sequence (?\...) not recognized {#} m/(?\{#}:x/',
170 '/(?\=x/' => 'Sequence (?\...) not recognized {#} m/(?\{#}=x/',
171 '/(?\!x/' => 'Sequence (?\...) not recognized {#} m/(?\{#}!x/',
172 '/(?\<=x/' => 'Sequence (?\...) not recognized {#} m/(?\{#}<=x/',
173 '/(?\<!x/' => 'Sequence (?\...) not recognized {#} m/(?\{#}<!x/',
174 '/(?\>x/' => 'Sequence (?\...) not recognized {#} m/(?\{#}>x/',
175 '/(?^-i:foo)/' => 'Sequence (?^-...) not recognized {#} m/(?^-{#}i:foo)/',
176 '/(?^-i)foo/' => 'Sequence (?^-...) not recognized {#} m/(?^-{#}i)foo/',
177 '/(?^d:foo)/' => 'Sequence (?^d...) not recognized {#} m/(?^d{#}:foo)/',
178 '/(?^d)foo/' => 'Sequence (?^d...) not recognized {#} m/(?^d{#})foo/',
179 '/(?^lu:foo)/' => 'Regexp modifiers "l" and "u" are mutually exclusive {#} m/(?^lu{#}:foo)/',
180 '/(?^lu)foo/' => 'Regexp modifiers "l" and "u" are mutually exclusive {#} m/(?^lu{#})foo/',
181 '/(?da:foo)/' => 'Regexp modifiers "d" and "a" are mutually exclusive {#} m/(?da{#}:foo)/',
182 '/(?lil:foo)/' => 'Regexp modifier "l" may not appear twice {#} m/(?lil{#}:foo)/',
183 '/(?aaia:foo)/' => 'Regexp modifier "a" may appear a maximum of twice {#} m/(?aaia{#}:foo)/',
184 '/(?i-l:foo)/' => 'Regexp modifier "l" may not appear after the "-" {#} m/(?i-l{#}:foo)/',
186 '/((x)/' => 'Unmatched ( {#} m/({#}(x)/',
187 '/{(}/' => 'Unmatched ( {#} m/{({#}}/', # [perl #127599]
189 "/x{$inf_p1}/" => "Quantifier in {,} bigger than $inf_m1 {#} m/x{$inf_p1\{#}}/",
190 "/x{$inf_p1,}/" => "Quantifier in {,} bigger than $inf_m1 {#} m/x{$inf_p1\{#},}/",
191 "/x{01,2}/" => "Invalid quantifier in {,} {#} m/x{01{#},2}/",
192 "/x{1,02}/" => "Invalid quantifier in {,} {#} m/x{1,02{#}}/",
195 '/x**/' => 'Nested quantifiers {#} m/x**{#}/',
197 '/x[/' => 'Unmatched [ {#} m/x[{#}/',
199 '/*/', => 'Quantifier follows nothing {#} m/*{#}/',
201 '/\p{x/' => 'Missing right brace on \p{} {#} m/\p{{#}x/',
203 '/[\p{x]/' => 'Missing right brace on \p{} {#} m/[\p{{#}x]/',
205 '/(x)\2/' => 'Reference to nonexistent group {#} m/(x)\2{#}/',
207 '/\g/' => 'Unterminated \g... pattern {#} m/\g{#}/',
208 '/\g{1/' => 'Unterminated \g{...} pattern {#} m/\g{1{#}/',
209 '/\g{-abc}/' => 'Group name must start with a non-digit word character {#} m/\g{-{#}abc}/',
210 '/(?<;x/' => 'Group name must start with a non-digit word character {#} m/(?<;{#}x/',
212 'my $m = "\\\"; $m =~ $m', => 'Trailing \ in regex m/\/',
214 '/\x{ 1 /' => 'Missing right brace on \x{} {#} m/\x{ 1{#} /',
215 '/\x{X/' => 'Missing right brace on \x{} {#} m/\x{{#}X/',
217 '/[\x{X]/' => 'Missing right brace on \x{} {#} m/[\x{{#}X]/',
218 '/[\x{ A ]/' => 'Missing right brace on \x{} {#} m/[\x{ A{#} ]/',
220 '/\o{ 1 /' => 'Missing right brace on \o{} {#} m/\o{ 1{#} /',
221 '/\o{X/' => 'Missing right brace on \o{} {#} m/\o{{#}X/',
223 '/[\o{X]/' => 'Missing right brace on \o{} {#} m/[\o{{#}X]/',
224 '/[\o{ 7 ]/' => 'Missing right brace on \o{} {#} m/[\o{ 7{#} ]/',
226 '/[[:barf:]]/' => 'POSIX class [:barf:] unknown {#} m/[[:barf:]{#}]/',
228 '/[[=barf=]]/' => 'POSIX syntax [= =] is reserved for future extensions {#} m/[[=barf=]{#}]/',
230 '/[[.barf.]]/' => 'POSIX syntax [. .] is reserved for future extensions {#} m/[[.barf.]{#}]/',
232 '/[z-a]/' => 'Invalid [] range "z-a" {#} m/[z-a{#}]/',
234 '/\p/' => 'Empty \p {#} m/\p{#}/',
235 '/\P/' => 'Empty \P {#} m/\P{#}/',
236 '/\p{}/' => 'Empty \p{} {#} m/\p{{#}}/',
237 '/\P{}/' => 'Empty \P{} {#} m/\P{{#}}/',
239 '/a\b{cde/' => 'Missing right brace on \b{} {#} m/a\b{{#}cde/',
240 '/a\B{cde/' => 'Missing right brace on \B{} {#} m/a\B{{#}cde/',
242 '/\b{}/' => 'Empty \b{} {#} m/\b{}{#}/',
243 '/\B{}/' => 'Empty \B{} {#} m/\B{}{#}/',
245 '/\b{gc}/' => "'gc' is an unknown bound type {#} m/\\b{gc{#}}/",
246 '/\B{gc}/' => "'gc' is an unknown bound type {#} m/\\B{gc{#}}/",
248 '/(?[[[::]]])/' => "Unexpected ']' with no following ')' in (?[... {#} m/(?[[[::]]{#}])/",
249 '/(?[[[:w:]]])/' => "Unexpected ']' with no following ')' in (?[... {#} m/(?[[[:w:]]{#}])/",
250 '/(?[a])/' => 'Unexpected character {#} m/(?[a{#}])/',
251 '/(?[ + \t ])/' => 'Unexpected binary operator \'+\' with no preceding operand {#} m/(?[ +{#} \t ])/',
252 '/(?[ \cK - ( + \t ) ])/' => 'Unexpected binary operator \'+\' with no preceding operand {#} m/(?[ \cK - ( +{#} \t ) ])/',
253 '/(?[ \cK ( \t ) ])/' => 'Unexpected \'(\' with no preceding operator {#} m/(?[ \cK ({#} \t ) ])/',
254 '/(?[ \cK \t ])/' => 'Operand with no preceding operator {#} m/(?[ \cK \t{#} ])/',
255 '/(?[ \0004 ])/' => 'Need exactly 3 octal digits {#} m/(?[ \0004 {#}])/',
256 '/(?[ \05 ])/' => 'Need exactly 3 octal digits {#} m/(?[ \05 {#}])/',
257 '/(?[ \o{1038} ])/' => 'Non-octal character {#} m/(?[ \o{1038{#}} ])/',
258 '/(?[ \o{} ])/' => 'Empty \o{} {#} m/(?[ \o{}{#} ])/',
259 '/(?[ \x{defg} ])/' => 'Non-hex character {#} m/(?[ \x{defg{#}} ])/',
260 '/(?[ \xabcdef ])/' => 'Use \\x{...} for more than two hex characters {#} m/(?[ \xabc{#}def ])/',
261 '/(?[ \x{} ])/' => 'Empty \x{} {#} m/(?[ \x{}{#} ])/',
262 '/(?[ \cK + ) ])/' => 'Unexpected \')\' {#} m/(?[ \cK + ){#} ])/',
263 '/(?[ \cK + ])/' => 'Incomplete expression within \'(?[ ])\' {#} m/(?[ \cK + {#}])/',
264 '/(?[ ( ) ])/' => 'Incomplete expression within \'(?[ ])\' {#} m/(?[ ( ){#} ])/',
265 '/(?[[0]+()+])/' => 'Incomplete expression within \'(?[ ])\' {#} m/(?[[0]+(){#}+])/',
266 '/(?[ \p{foo} ])/' => 'Can\'t find Unicode property definition "foo" {#} m/(?[ \p{foo}{#} ])/',
267 '/(?[ \p{ foo = bar } ])/' => 'Can\'t find Unicode property definition "foo = bar" {#} m/(?[ \p{ foo = bar }{#} ])/',
268 '/(?[ \8 ])/' => 'Unrecognized escape \8 in character class {#} m/(?[ \8{#} ])/',
269 '/(?[ \t ]/' => "Unexpected ']' with no following ')' in (?[... {#} m/(?[ \\t ]{#}/",
270 '/(?[ [ \t ]/' => "Syntax error in (?[...]) {#} m/(?[ [ \\t ]{#}/",
271 '/(?[ \t ] ]/' => "Unexpected ']' with no following ')' in (?[... {#} m/(?[ \\t ]{#} ]/",
272 '/(?[ [ ] ]/' => "Syntax error in (?[...]) {#} m/(?[ [ ] ]{#}/",
273 '/(?[ \t + \e # This was supposed to be a comment ])/' =>
274 "Syntax error in (?[...]) {#} m/(?[ \\t + \\e # This was supposed to be a comment ]){#}/",
275 '/(?[ ])/' => 'Incomplete expression within \'(?[ ])\' {#} m/(?[ {#}])/',
276 'm/(?[[a-\d]])/' => 'False [] range "a-\d" {#} m/(?[[a-\d{#}]])/',
277 'm/(?[[\w-x]])/' => 'False [] range "\w-" {#} m/(?[[\w-{#}x]])/',
278 'm/(?[[a-\pM]])/' => 'False [] range "a-\pM" {#} m/(?[[a-\pM{#}]])/',
279 'm/(?[[\pM-x]])/' => 'False [] range "\pM-" {#} m/(?[[\pM-{#}x]])/',
280 'm/(?[[^\N{LATIN CAPITAL LETTER A WITH MACRON AND GRAVE}]])/' => '\N{} here is restricted to one character {#} m/(?[[^\N{U+100.300{#}}]])/',
281 'm/(?[ \p{Digit} & (?^(?[ \p{Thai} | \p{Lao} ]))])/' => 'Sequence (?^(...) not recognized {#} m/(?[ \p{Digit} & (?^({#}?[ \p{Thai} | \p{Lao} ]))])/',
282 'm/(?[ \p{Digit} & (?(?[ \p{Thai} | \p{Lao} ]))])/' => 'Unexpected character {#} m/(?[ \p{Digit} & (?{#}(?[ \p{Thai} | \p{Lao} ]))])/',
283 'm/\p{Is_Is_Any}/' => 'Unknown user-defined property name \p{main::Is_Is_Any}',
284 'm/\o{/' => 'Missing right brace on \o{} {#} m/\o{{#}/',
285 'm/\o/' => 'Missing braces on \o{} {#} m/\o{#}/',
286 'm/\o{}/' => 'Empty \o{} {#} m/\o{}{#}/',
287 'm/[\o{]/' => 'Missing right brace on \o{} {#} m/[\o{{#}]/',
288 'm/[\o]/' => 'Missing braces on \o{} {#} m/[\o{#}]/',
289 'm/[\o{}]/' => 'Empty \o{} {#} m/[\o{}{#}]/',
290 'm/(?^-i:foo)/' => 'Sequence (?^-...) not recognized {#} m/(?^-{#}i:foo)/',
291 'm/\87/' => 'Reference to nonexistent group {#} m/\87{#}/',
292 'm/a\87/' => 'Reference to nonexistent group {#} m/a\87{#}/',
293 'm/a\97/' => 'Reference to nonexistent group {#} m/a\97{#}/',
294 'm/(*DOOF)/' => 'Unknown verb pattern \'DOOF\' {#} m/(*DOOF){#}/',
295 'm/(?&a/' => 'Sequence (?&... not terminated {#} m/(?&a{#}/',
296 'm/(?P=/' => 'Sequence ?P=... not terminated {#} m/(?P={#}/',
297 "m/(?'/" => "Sequence (?'... not terminated {#} m/(?'{#}/",
298 "m/(?</" => "Sequence (?<... not terminated {#} m/(?<{#}/",
299 'm/(?&/' => 'Sequence (?&... not terminated {#} m/(?&{#}/',
300 'm/(?(</' => 'Sequence (?(<... not terminated {#} m/(?(<{#}/',
301 "m/(?('/" => "Sequence (?('... not terminated {#} m/(?('{#}/",
302 'm/\g{/' => 'Sequence \g{... not terminated {#} m/\g{{#}/',
303 'm/\k</' => 'Sequence \k<... not terminated {#} m/\k<{#}/',
304 '/((?# This is a comment in the middle of a token)?:foo)/' => 'In \'(?...)\', the \'(\' and \'?\' must be adjacent {#} m/((?# This is a comment in the middle of a token)?{#}:foo)/',
305 '/((?# This is a comment in the middle of a token)*FAIL)/' => 'In \'(*VERB...)\', the \'(\' and \'*\' must be adjacent {#} m/((?# This is a comment in the middle of a token)*{#}FAIL)/',
306 '/((?# This is a comment in the middle of a token)*script_run:foo)/' => 'In \'(*...)\', the \'(\' and \'*\' must be adjacent {#} m/((?# This is a comment in the middle of a token)*{#}script_run:foo)/',
308 '/(*script_runfoo)/' => 'Unknown \'(*...)\' construct \'script_runfoo\' {#} m/(*script_runfoo){#}/',
309 '/(*srfoo)/' => 'Unknown \'(*...)\' construct \'srfoo\' {#} m/(*srfoo){#}/',
310 '/(*script_run)/' => '\'(*script_run\' requires a terminating \':\' {#} m/(*script_run{#})/',
311 '/(*sr)/' => '\'(*sr\' requires a terminating \':\' {#} m/(*sr{#})/',
312 '/(*pla)/' => '\'(*pla\' requires a terminating \':\' {#} m/(*pla{#})/',
313 '/(*script_run/' => 'Unterminated \'(*...\' construct {#} m/(*script_run{#}/',
314 '/(*sr/' => 'Unterminated \'(*...\' construct {#} m/(*sr{#}/',
315 '/(*script_run:foo/' => 'Unterminated \'(*...\' argument {#} m/(*script_run:foo{#}/',
316 '/(*sr:foo/' => 'Unterminated \'(*...\' argument {#} m/(*sr:foo{#}/',
317 '/(?[\ &!])/' => 'Incomplete expression within \'(?[ ])\' {#} m/(?[\ &!{#}])/', # [perl #126180]
318 '/(?[\ +!])/' => 'Incomplete expression within \'(?[ ])\' {#} m/(?[\ +!{#}])/', # [perl #126180]
319 '/(?[\ -!])/' => 'Incomplete expression within \'(?[ ])\' {#} m/(?[\ -!{#}])/', # [perl #126180]
320 '/(?[\ ^!])/' => 'Incomplete expression within \'(?[ ])\' {#} m/(?[\ ^!{#}])/', # [perl #126180]
321 '/(?[\ |!])/' => 'Incomplete expression within \'(?[ ])\' {#} m/(?[\ |!{#}])/', # [perl #126180]
322 '/(?[()-!])/' => 'Incomplete expression within \'(?[ ])\' {#} m/(?[(){#}-!])/', # [perl #126204]
323 '/(?[!()])/' => 'Incomplete expression within \'(?[ ])\' {#} m/(?[!(){#}])/', # [perl #126404]
324 '/\w{/' => 'Unescaped left brace in regex is illegal here {#} m/\w{{#}/',
325 '/\q{/' => 'Unescaped left brace in regex is illegal here {#} m/\q{{#}/',
326 '/\A{/' => 'Unescaped left brace in regex is illegal here {#} m/\A{{#}/',
327 '/(?<=/' => 'Sequence (?<=... not terminated {#} m/(?<={#}/', # [perl #128170]
328 '/(?<!/' => 'Sequence (?<!... not terminated {#} m/(?<!{#}/',
329 '/(?!/' => 'Sequence (?!... not terminated {#} m/(?!{#}/',
330 '/(?=/' => 'Sequence (?=... not terminated {#} m/(?={#}/',
331 '/\p{vertical
\v tab}/' => 'Can\'t find Unicode property definition "vertical
\v tab" {#} m/\\p{vertical
\v tab}{#}/', # [perl #132055]
332 "/$bug133423/" => "Unexpected ']' with no following ')' in (?[... {#} m/(?[(?^:(?[\\
\0]))\\]{#}
\0|2[^^]\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80])R.\\670/",
333 '/[^/' => 'Unmatched [ {#} m/[{#}^/', # [perl #133767]
334 '/\p{Is_Other_Alphabetic=F}/ ' => 'Can\'t find Unicode property definition "Is_Other_Alphabetic=F" {#} m/\p{Is_Other_Alphabetic=F}{#}/',
335 '/\p{Is_Other_Alphabetic=F}/ ' => 'Can\'t find Unicode property definition "Is_Other_Alphabetic=F" {#} m/\p{Is_Other_Alphabetic=F}{#}/',
336 '/\x{100}(?(/' => 'Unknown switch condition (?(...)) {#} m/\\x{100}(?({#}/', # [perl #133896]
337 '/(?[\N{KEYCAP DIGIT NINE}/' => '\N{} here is restricted to one character {#} m/(?[\\N{U+39.FE0F.20E3{#}}/', # [perl #133988]
338 '/0000000000000000[\N{U+0.00}0000/' => 'Unmatched [ {#} m/0000000000000000[{#}\N{U+0.00}0000/', # [perl #134059]
339 '/\p{nv=\b5\b}/' => 'Can\'t find Unicode property definition "nv=\\b5\\b" {#} m/\\p{nv=\\b5\\b}{#}/',
340 '/\p{nv=:(?g)10:}/' => 'Use of modifier \'g\' is not allowed in Unicode property wildcard subpatterns {#} m/(?g{#})10/',
341 '/\p{gc=:L*:}/' => 'Use of quantifier \'*\' is not allowed in Unicode property wildcard subpatterns {#} m/L*{#}/',
342 '/\p{gc=:L\G:}/' => 'Use of \'\G\' is not allowed in Unicode property wildcard subpatterns {#} m/L\G{#}/',
343 '/\p{gc=:(?a)L:}/' => 'Use of modifier \'a\' is not allowed in Unicode property wildcard subpatterns {#} m/(?a){#}L/',
344 '/\p{gc=:(?u)L:}/' => 'Use of modifier \'u\' is not allowed in Unicode property wildcard subpatterns {#} m/(?u){#}L/',
345 '/\p{gc=:(?d)L:}/' => 'Use of modifier \'d\' is not allowed in Unicode property wildcard subpatterns {#} m/(?d){#}L/',
346 '/\p{gc=:(?l)L:}/' => 'Use of modifier \'l\' is not allowed in Unicode property wildcard subpatterns {#} m/(?l){#}L/',
347 '/\p{gc=:(?-m)L:}/' => 'Use of modifier \'-m\' is not allowed in Unicode property wildcard subpatterns {#} m/(?-m{#})L/',
348 '/\p{gc=:\pS:}/' => 'Use of \'\\pS\' is not allowed in Unicode property wildcard subpatterns {#} m/\\pS{#}/',
349 '/\p{gc=:\PS:}/' => 'Use of \'\\PS\' is not allowed in Unicode property wildcard subpatterns {#} m/\\PS{#}/',
350 '/\p{gc=:[\pS]:}/' => 'Use of \'\\pS\' is not allowed in Unicode property wildcard subpatterns {#} m/[\\pS{#}]/',
351 '/\p{gc=:[\PS]:}/' => 'Use of \'\\PS\' is not allowed in Unicode property wildcard subpatterns {#} m/[\\PS{#}]/',
352 '/(?[\p{name=KATAKANA LETTER AINU P}])/' => 'Unicode string properties are not implemented in (?[...]) {#} m/(?[\p{name=KATAKANA LETTER AINU P}{#}])/',
353 '/(?[ (?^x:(?[ ])) ])/' => 'Incomplete expression within \'(?[ ])\' {#} m/(?[ (?^x:(?[ {#}])) ])/',
354 '/(?[ (?x:(?[ ])) ])/' => 'Incomplete expression within \'(?[ ])\' {#} m/(?[ (?x:(?[ {#}])) ])/', # GH #16779
357 # These are messages that are death under 'use re "strict"', and may or may
358 # not warn otherwise. See comment before @warning as to why some have a
359 # \x{100} in them. This array has 3 elements per construct. [0] is the regex
360 # to use; [1] is the message under no strict (empty to not warn), and [2] is
362 my @death_only_under_strict = (
364 => 'Use \x{...} for more than two hex characters {#} m/\xABC{#}/',
366 => 'Use \x{...} for more than two hex characters {#} m/[\xABC{#}]/',
368 # some messages below aren't all category 'regexp'. (Hence we have to
369 # turn off 'digit' messages as well below)
370 'm/\xAG/' => 'Non-hex character \'G\' terminates \x early. Resolved as "\x0AG" {#} m/\xA{#}G/',
371 => 'Non-hex character {#} m/\xAG{#}/',
372 'm/[\xAG]/' => 'Non-hex character \'G\' terminates \x early. Resolved as "\x0AG" {#} m/[\xA{#}G]/',
373 => 'Non-hex character {#} m/[\xAG{#}]/',
374 'm/\o{789}/' => 'Non-octal character \'8\' terminates \o early. Resolved as "\o{007}" {#} m/\o{789}{#}/',
375 => 'Non-octal character {#} m/\o{78{#}9}/',
376 'm/[\o{789}]/' => 'Non-octal character \'8\' terminates \o early. Resolved as "\o{007}" {#} m/[\o{789}{#}]/',
377 => 'Non-octal character {#} m/[\o{78{#}9}]/',
379 => 'Empty \x{} {#} m/\x{}{#}/',
381 => 'Empty \x{} {#} m/[\x{}{#}]/',
382 'm/\x{ABCDEFG}/' => 'Non-hex character \'G\' terminates \x early. Resolved as "\x{ABCDEF}" {#} m/\x{ABCDEFG}{#}/',
383 => 'Non-hex character {#} m/\x{ABCDEFG{#}}/',
384 'm/[\x{ABCDEFG}]/' => 'Non-hex character \'G\' terminates \x early. Resolved as "\x{ABCDEF}" {#} m/[\x{ABCDEFG}{#}]/',
385 => 'Non-hex character {#} m/[\x{ABCDEFG{#}}]/',
386 "m'[\\y]\\x{100}'" => 'Unrecognized escape \y in character class passed through {#} m/[\y{#}]\x{100}/',
387 => 'Unrecognized escape \y in character class {#} m/[\y{#}]\x{100}/',
388 'm/[a-\d]\x{100}/' => 'False [] range "a-\d" {#} m/[a-\d{#}]\x{100}/',
389 => 'False [] range "a-\d" {#} m/[a-\d{#}]\x{100}/',
390 'm/[\w-x]\x{100}/' => 'False [] range "\w-" {#} m/[\w-{#}x]\x{100}/',
391 => 'False [] range "\w-" {#} m/[\w-{#}x]\x{100}/',
392 'm/[a-\pM]\x{100}/' => 'False [] range "a-\pM" {#} m/[a-\pM{#}]\x{100}/',
393 => 'False [] range "a-\pM" {#} m/[a-\pM{#}]\x{100}/',
394 'm/[\pM-x]\x{100}/' => 'False [] range "\pM-" {#} m/[\pM-{#}x]\x{100}/',
395 => 'False [] range "\pM-" {#} m/[\pM-{#}x]\x{100}/',
396 'm/[^\N{LATIN CAPITAL LETTER A WITH MACRON AND GRAVE}]/' => 'Using just the first character returned by \N{} in character class {#} m/[^\N{U+100.300}{#}]/',
397 => '\N{} here is restricted to one character {#} m/[^\N{U+100.300{#}}]/',
398 'm/[\x03-\N{LATIN CAPITAL LETTER A WITH MACRON AND GRAVE}]/' => 'Using just the first character returned by \N{} in character class {#} m/[\x03-\N{U+100.300}{#}]/',
399 => '\N{} here is restricted to one character {#} m/[\x03-\N{U+100.300{#}}]/',
400 'm/[\N{LATIN CAPITAL LETTER A WITH MACRON AND GRAVE}-\x{10FFFF}]/' => 'Using just the first character returned by \N{} in character class {#} m/[\N{U+100.300}{#}-\x{10FFFF}]/',
401 => '\N{} here is restricted to one character {#} m/[\N{U+100.300{#}}-\x{10FFFF}]/',
402 '/[\08]/' => 'Non-octal character \'8\' terminates \0 early. Resolved as "\0008" {#} m/[\08{#}]/',
403 => 'Need exactly 3 octal digits {#} m/[\08{#}]/',
404 '/[\018]/' => 'Non-octal character \'8\' terminates \0 early. Resolved as "\0018" {#} m/[\018{#}]/',
405 => 'Need exactly 3 octal digits {#} m/[\018{#}]/',
407 => 'Need exactly 3 octal digits {#} m/[\_\0]{#}/',
409 => 'Need exactly 3 octal digits {#} m/[\07]{#}/',
411 => 'Need exactly 3 octal digits {#} m/[\0005]{#}/',
412 '/[\8\9]\x{100}/' => ['Unrecognized escape \8 in character class passed through {#} m/[\8{#}\9]\x{100}/',
413 'Unrecognized escape \9 in character class passed through {#} m/[\8\9{#}]\x{100}/',
415 => 'Unrecognized escape \8 in character class {#} m/[\8{#}\9]\x{100}/',
416 '/[a-\d]\x{100}/' => 'False [] range "a-\d" {#} m/[a-\d{#}]\x{100}/',
417 => 'False [] range "a-\d" {#} m/[a-\d{#}]\x{100}/',
418 '/[\d-b]\x{100}/' => 'False [] range "\d-" {#} m/[\d-{#}b]\x{100}/',
419 => 'False [] range "\d-" {#} m/[\d-{#}b]\x{100}/',
420 '/[\s-\d]\x{100}/' => 'False [] range "\s-" {#} m/[\s-{#}\d]\x{100}/',
421 => 'False [] range "\s-" {#} m/[\s-{#}\d]\x{100}/',
422 '/[\d-\s]\x{100}/' => 'False [] range "\d-" {#} m/[\d-{#}\s]\x{100}/',
423 => 'False [] range "\d-" {#} m/[\d-{#}\s]\x{100}/',
424 '/[a-[:digit:]]\x{100}/' => 'False [] range "a-[:digit:]" {#} m/[a-[:digit:]{#}]\x{100}/',
425 => 'False [] range "a-[:digit:]" {#} m/[a-[:digit:]{#}]\x{100}/',
426 '/[[:digit:]-b]\x{100}/' => 'False [] range "[:digit:]-" {#} m/[[:digit:]-{#}b]\x{100}/',
427 => 'False [] range "[:digit:]-" {#} m/[[:digit:]-{#}b]\x{100}/',
428 '/[[:alpha:]-[:digit:]]\x{100}/' => 'False [] range "[:alpha:]-" {#} m/[[:alpha:]-{#}[:digit:]]\x{100}/',
429 => 'False [] range "[:alpha:]-" {#} m/[[:alpha:]-{#}[:digit:]]\x{100}/',
430 '/[[:digit:]-[:alpha:]]\x{100}/' => 'False [] range "[:digit:]-" {#} m/[[:digit:]-{#}[:alpha:]]\x{100}/',
431 => 'False [] range "[:digit:]-" {#} m/[[:digit:]-{#}[:alpha:]]\x{100}/',
432 '/[a\zb]\x{100}/' => 'Unrecognized escape \z in character class passed through {#} m/[a\z{#}b]\x{100}/',
433 => 'Unrecognized escape \z in character class {#} m/[a\z{#}b]\x{100}/',
435 => 'Literal vertical space in [] is illegal except under /x {#} m/[a
\f{#}b]/',
436 '/:{4,a}/' => 'Unescaped left brace in regex is passed through {#} m/:{{#}4,a}/',
437 => 'Unescaped left brace in regex is illegal here {#} m/:{{#}4,a}/',
438 '/xa{3\,4}y/' => 'Unescaped left brace in regex is passed through {#} m/xa{{#}3\,4}y/',
439 => 'Unescaped left brace in regex is illegal here {#} m/xa{{#}3\,4}y/',
440 '/\\${[^\\}]*}/' => 'Unescaped left brace in regex is passed through {#} m/\\${{#}[^\\}]*}/',
441 => 'Unescaped left brace in regex is illegal here {#} m/\\${{#}[^\\}]*}/',
442 '/.{/' => 'Unescaped left brace in regex is passed through {#} m/.{{#}/',
443 => 'Unescaped left brace in regex is illegal here {#} m/.{{#}/',
444 '/[x]{/' => 'Unescaped left brace in regex is passed through {#} m/[x]{{#}/',
445 => 'Unescaped left brace in regex is illegal here {#} m/[x]{{#}/',
446 '/\p{Latin}{/' => 'Unescaped left brace in regex is passed through {#} m/\p{Latin}{{#}/',
447 => 'Unescaped left brace in regex is illegal here {#} m/\p{Latin}{{#}/',
449 => "Empty \\x {#} m/\\x{100}\\x{#}/",
450 '/\o{ 1 20 }/' => 'Non-octal character \' \' terminates \o early. Resolved as "\o{001}" {#} m/\o{ 1 20 }{#}/',
451 => 'Non-octal character {#} m/\\o{ 1 {#}20 }/',
452 '/\x{ 5 0 }/' => 'Non-hex character \' \' terminates \x early. Resolved as "\x{05}" {#} m/\x{ 5 0 }{#}/',
453 => 'Non-hex character {#} m/\\x{ 5 {#}0 }/',
456 # These need the character 'ネ' as a marker for mark_as_utf8()
457 my @death_utf8 = mark_as_utf8(
458 '/ネ(?<= .*)/' => 'Lookbehind longer than 255 not implemented in regex m/ネ(?<= .*)/',
460 '/(?<= ネ{1000})/' => 'Lookbehind longer than 255 not implemented in regex m/(?<= ネ{1000})/',
462 '/ネ(?ネ)ネ/' => 'Sequence (?ネ...) not recognized {#} m/ネ(?ネ{#})ネ/',
464 '/ネ(?(1ネ))ネ/' => 'Switch condition not recognized {#} m/ネ(?(1ネ{#}))ネ/',
466 '/(?(1)ネ|y|ヌ)/' => 'Switch (?(condition)... contains too many branches {#} m/(?(1)ネ|y|{#}ヌ)/',
468 '/(?(ネ)y|ネ)/' => 'Unknown switch condition (?(...)) {#} m/(?(ネ{#})y|ネ)/',
470 '/ネ(?/' => 'Sequence (? incomplete {#} m/ネ(?{#}/',
472 '/ネ(?;ネ/' => 'Sequence (?;...) not recognized {#} m/ネ(?;{#}ネ/',
473 '/ネ(?<;ネ/' => 'Group name must start with a non-digit word character {#} m/ネ(?<;{#}ネ/',
474 '/ネ(?\ixネ/' => 'Sequence (?\...) not recognized {#} m/ネ(?\{#}ixネ/',
475 '/ネ(?^lu:ネ)/' => 'Regexp modifiers "l" and "u" are mutually exclusive {#} m/ネ(?^lu{#}:ネ)/',
476 '/ネ(?lil:ネ)/' => 'Regexp modifier "l" may not appear twice {#} m/ネ(?lil{#}:ネ)/',
477 '/ネ(?aaia:ネ)/' => 'Regexp modifier "a" may appear a maximum of twice {#} m/ネ(?aaia{#}:ネ)/',
478 '/ネ(?i-l:ネ)/' => 'Regexp modifier "l" may not appear after the "-" {#} m/ネ(?i-l{#}:ネ)/',
480 '/ネ((ネ)/' => 'Unmatched ( {#} m/ネ({#}(ネ)/',
482 "/ネ{$inf_p1}ネ/" => "Quantifier in {,} bigger than $inf_m1 {#} m/ネ{$inf_p1\{#}}ネ/",
483 "/ネ{$inf_p1,}ネ/" => "Quantifier in {,} bigger than $inf_m1 {#} m/ネ{$inf_p1\{#},}ネ/",
484 "/ネ{01}ネ/" => "Invalid quantifier in {,} {#} m/ネ{01{#}}ネ/",
485 "/ネ{1,02}ネ/" => "Invalid quantifier in {,} {#} m/ネ{1,02{#}}ネ/",
488 '/ネ**ネ/' => 'Nested quantifiers {#} m/ネ**{#}ネ/',
490 '/ネ[ネ/' => 'Unmatched [ {#} m/ネ[{#}ネ/',
492 '/*ネ/', => 'Quantifier follows nothing {#} m/*{#}ネ/',
494 '/ネ\p{ネ/' => 'Missing right brace on \p{} {#} m/ネ\p{{#}ネ/',
496 '/(ネ)\2ネ/' => 'Reference to nonexistent group {#} m/(ネ)\2{#}ネ/',
498 '/\g{ネ/; #no latin1' => 'Sequence \g{... not terminated {#} m/\g{ネ{#}/',
500 'my $m = "ネ\\\"; $m =~ $m', => 'Trailing \ in regex m/ネ\/',
502 '/\x{ネ/' => 'Missing right brace on \x{} {#} m/\x{{#}ネ/',
503 '/ネ[\x{ネ]ネ/' => 'Missing right brace on \x{} {#} m/ネ[\x{{#}ネ]ネ/',
504 '/ネ[\x{ネ]/' => 'Missing right brace on \x{} {#} m/ネ[\x{{#}ネ]/',
506 '/ネ\o{ネ/' => 'Missing right brace on \o{} {#} m/ネ\o{{#}ネ/',
508 '/[ネ-a]ネ/' => 'Invalid [] range "ネ-a" {#} m/[ネ-a{#}]ネ/',
510 '/ネ\p{}ネ/' => 'Empty \p{} {#} m/ネ\p{{#}}ネ/',
512 '/ネ(?[[[:ネ]]])ネ/' => "Unexpected ']' with no following ')' in (?[... {#} m/ネ(?[[[:ネ]]{#}])ネ/",
513 '/ネ(?[[[:ネ: ])ネ/' => "Syntax error in (?[...]) {#} m/ネ(?[[[:ネ: ])ネ{#}/",
514 '/ネ(?[[[::]]])ネ/' => "Unexpected ']' with no following ')' in (?[... {#} m/ネ(?[[[::]]{#}])ネ/",
515 '/ネ(?[[[:ネ:]]])ネ/' => "Unexpected ']' with no following ')' in (?[... {#} m/ネ(?[[[:ネ:]]{#}])ネ/",
516 '/ネ(?[ネ])ネ/' => 'Unexpected character {#} m/ネ(?[ネ{#}])ネ/',
517 '/ネ(?[ + [ネ] ])/' => 'Unexpected binary operator \'+\' with no preceding operand {#} m/ネ(?[ +{#} [ネ] ])/',
518 '/ネ(?[ \cK - ( + [ネ] ) ])/' => 'Unexpected binary operator \'+\' with no preceding operand {#} m/ネ(?[ \cK - ( +{#} [ネ] ) ])/',
519 '/ネ(?[ \cK ( [ネ] ) ])/' => 'Unexpected \'(\' with no preceding operator {#} m/ネ(?[ \cK ({#} [ネ] ) ])/',
520 '/ネ(?[ \cK [ネ] ])ネ/' => 'Operand with no preceding operator {#} m/ネ(?[ \cK [ネ{#}] ])ネ/',
521 '/ネ(?[ \0004 ])ネ/' => 'Need exactly 3 octal digits {#} m/ネ(?[ \0004 {#}])ネ/',
522 '/(?[ \o{ネ} ])ネ/' => 'Non-octal character {#} m/(?[ \o{ネ{#}} ])ネ/',
523 '/ネ(?[ \o{} ])ネ/' => 'Empty \o{} {#} m/ネ(?[ \o{}{#} ])ネ/',
524 '/(?[ \x{ネ} ])ネ/' => 'Non-hex character {#} m/(?[ \x{ネ{#}} ])ネ/',
525 '/(?[ \p{ネ} ])/' => 'Can\'t find Unicode property definition "ネ" {#} m/(?[ \p{ネ}{#} ])/',
526 '/(?[ \p{ ネ = bar } ])/' => 'Can\'t find Unicode property definition "ネ = bar" {#} m/(?[ \p{ ネ = bar }{#} ])/',
527 '/ネ(?[ \t ]/' => "Unexpected ']' with no following ')' in (?[... {#} m/ネ(?[ \\t ]{#}/",
528 '/(?[ \t + \e # ネ This was supposed to be a comment ])/' =>
529 "Syntax error in (?[...]) {#} m/(?[ \\t + \\e # ネ This was supposed to be a comment ]){#}/",
530 'm/(*ネ)ネ/' => q<Unknown '(*...)' construct 'ネ' {#} m/(*ネ){#}ネ/>,
531 '/\cネ/' => "Character following \"\\c\" must be printable ASCII {#} m/\\cネ{#}/",
532 '/[\cネ]/' => "Character following \"\\c\" must be printable ASCII {#} m/[\\cネ{#}]/",
533 '/\b{ネ}/' => "'ネ' is an unknown bound type {#} m/\\b{ネ{#}}/",
534 '/\B{ネ}/' => "'ネ' is an unknown bound type {#} m/\\B{ネ{#}}/",
536 push @death, @death_utf8;
538 my @death_utf8_only_under_strict = (
539 "m'ネ[\\y]ネ'" => 'Unrecognized escape \y in character class passed through {#} m/ネ[\y{#}]ネ/',
540 => 'Unrecognized escape \y in character class {#} m/ネ[\y{#}]ネ/',
541 'm/ネ[ネ-\d]ネ/' => 'False [] range "ネ-\d" {#} m/ネ[ネ-\d{#}]ネ/',
542 => 'False [] range "ネ-\d" {#} m/ネ[ネ-\d{#}]ネ/',
543 'm/ネ[\w-ネ]ネ/' => 'False [] range "\w-" {#} m/ネ[\w-{#}ネ]ネ/',
544 => 'False [] range "\w-" {#} m/ネ[\w-{#}ネ]ネ/',
545 'm/ネ[ネ-\pM]ネ/' => 'False [] range "ネ-\pM" {#} m/ネ[ネ-\pM{#}]ネ/',
546 => 'False [] range "ネ-\pM" {#} m/ネ[ネ-\pM{#}]ネ/',
547 '/ネ[ネ-[:digit:]]ネ/' => 'False [] range "ネ-[:digit:]" {#} m/ネ[ネ-[:digit:]{#}]ネ/',
548 => 'False [] range "ネ-[:digit:]" {#} m/ネ[ネ-[:digit:]{#}]ネ/',
549 '/ネ[\d-\s]ネ/' => 'False [] range "\d-" {#} m/ネ[\d-{#}\s]ネ/',
550 => 'False [] range "\d-" {#} m/ネ[\d-{#}\s]ネ/',
551 '/ネ[a\zb]ネ/' => 'Unrecognized escape \z in character class passed through {#} m/ネ[a\z{#}b]ネ/',
552 => 'Unrecognized escape \z in character class {#} m/ネ[a\z{#}b]ネ/',
554 # Tests involving a user-defined charnames translator are in pat_advanced.t
556 # In the following arrays of warnings, the value can be an array of things to
557 # expect. If the empty string, it means no warning should be raised.
560 # Key-value pairs of code/error of code that should have non-fatal regexp
561 # warnings. Most currently have \x{100} appended to them to force them to be
562 # upgraded to UTF-8, and the first pass restarted. Previously this would
563 # cause some warnings to be output twice. This tests that that behavior has
567 'm/\b*\x{100}/' => '\b* matches null string many times {#} m/\b*{#}\x{100}/',
568 '/\b{g}/a' => "Using /u for '\\b{g}' instead of /a {#} m/\\b{g}{#}/",
569 '/\B{gcb}/a' => "Using /u for '\\B{gcb}' instead of /a {#} m/\\B{gcb}{#}/",
570 'm/[:blank:]\x{100}/' => 'POSIX syntax [: :] belongs inside character classes {#} m/[:blank:]{#}\x{100}/',
571 'm/[[:cntrl:]][:^ascii:]\x{100}/' => 'POSIX syntax [: :] belongs inside character classes {#} m/[[:cntrl:]][:^ascii:]{#}\x{100}/',
572 'm/[[:ascii]]\x{100}/' => "Assuming NOT a POSIX class since there is no terminating ':' {#} m/[[:ascii{#}]]\\x{100}/",
573 'm/(?[[:word]])\x{100}/' => "Assuming NOT a POSIX class since there is no terminating ':' {#} m/(?[[:word{#}]])\\x{100}/",
574 "m'\\y\\x{100}'" => 'Unrecognized escape \y passed through {#} m/\y{#}\x{100}/',
575 '/x{3,1}/' => 'Quantifier {n,m} with n > m can\'t match {#} m/x{3,1}{#}/',
576 '/\08/' => 'Non-octal character \'8\' terminates \0 early. Resolved as "\0008" {#} m/\08{#}/',
578 '/\018/' => 'Non-octal character \'8\' terminates \0 early. Resolved as "\0018" {#} m/\018{#}/',
579 '/(?=a)*/' => '(?=a)* matches null string many times {#} m/(?=a)*{#}/',
580 'my $x = \'\m\'; qr/a$x/' => 'Unrecognized escape \m passed through {#} m/a\m{#}/',
581 '/\q/' => 'Unrecognized escape \q passed through {#} m/\q{#}/',
582 '/\q\p{Any}/' => 'Unrecognized escape \q passed through {#} m/\q{#}\p{Any}/',
584 # These two tests do not include the marker, because regcomp.c no
585 # longer knows where it goes by the time this warning is emitted.
586 # See [perl #122680] regcomp warning gives wrong position of
588 '/(?=a){1,3}\x{100}/' => 'Quantifier unexpected on zero-length expression in regex m/(?=a){1,3}\x{100}/',
589 '/(a|b)(?=a){3}\x{100}/' => 'Quantifier unexpected on zero-length expression in regex m/(a|b)(?=a){3}\x{100}/',
593 '/[:alpha:]\x{100}/' => 'POSIX syntax [: :] belongs inside character classes {#} m/[:alpha:]{#}\x{100}/',
594 '/[:zog:]\x{100}/' => 'POSIX syntax [: :] belongs inside character classes (but this one isn\'t fully valid) {#} m/[:zog:]{#}\x{100}/',
595 '/[.zog.]\x{100}/' => 'POSIX syntax [. .] belongs inside character classes (but this one isn\'t implemented) {#} m/[.zog.]{#}\x{100}/',
597 '/(?c)\x{100}/' => 'Useless (?c) - use /gc modifier {#} m/(?c{#})\x{100}/',
598 '/(?-c)\x{100}/' => 'Useless (?-c) - don\'t use /gc modifier {#} m/(?-c{#})\x{100}/',
599 '/(?g)\x{100}/' => 'Useless (?g) - use /g modifier {#} m/(?g{#})\x{100}/',
600 '/(?-g)\x{100}/' => 'Useless (?-g) - don\'t use /g modifier {#} m/(?-g{#})\x{100}/',
601 '/(?o)\x{100}/' => 'Useless (?o) - use /o modifier {#} m/(?o{#})\x{100}/',
602 '/(?-o)\x{100}/' => 'Useless (?-o) - don\'t use /o modifier {#} m/(?-o{#})\x{100}/',
603 '/(?g-o)\x{100}/' => [ 'Useless (?g) - use /g modifier {#} m/(?g{#}-o)\x{100}/',
604 'Useless (?-o) - don\'t use /o modifier {#} m/(?g-o{#})\x{100}/',
606 '/(?g-c)\x{100}/' => [ 'Useless (?g) - use /g modifier {#} m/(?g{#}-c)\x{100}/',
607 'Useless (?-c) - don\'t use /gc modifier {#} m/(?g-c{#})\x{100}/',
609 # (?c) means (?g) error won't be thrown
610 '/(?o-cg)\x{100}/' => [ 'Useless (?o) - use /o modifier {#} m/(?o{#}-cg)\x{100}/',
611 'Useless (?-c) - don\'t use /gc modifier {#} m/(?o-c{#}g)\x{100}/',
613 '/(?ogc)\x{100}/' => [ 'Useless (?o) - use /o modifier {#} m/(?o{#}gc)\x{100}/',
614 'Useless (?g) - use /g modifier {#} m/(?og{#}c)\x{100}/',
615 'Useless (?c) - use /gc modifier {#} m/(?ogc{#})\x{100}/',
617 '/a{1,1}?\x{100}/' => 'Useless use of greediness modifier \'?\' {#} m/a{1,1}?{#}\x{100}/',
618 "/(?[ [ % - % ] ])/" => "",
619 "/(?[ [ : - \\x$colon_hex ] ])\\x{100}/" => "\": - \\x$colon_hex \" is more clearly written simply as \":\" {#} m/(?[ [ : - \\x$colon_hex {#}] ])\\x{100}/",
620 "/(?[ [ \\x$colon_hex - : ] ])\\x{100}/" => "\"\\x$colon_hex\ - : \" is more clearly written simply as \":\" {#} m/(?[ [ \\x$colon_hex - : {#}] ])\\x{100}/",
621 "/(?[ [ \\t - \\x$tab_hex ] ])\\x{100}/" => "\"\\t - \\x$tab_hex \" is more clearly written simply as \"\\t\" {#} m/(?[ [ \\t - \\x$tab_hex {#}] ])\\x{100}/",
622 "/(?[ [ \\x$tab_hex - \\t ] ])\\x{100}/" => "\"\\x$tab_hex\ - \\t \" is more clearly written simply as \"\\t\" {#} m/(?[ [ \\x$tab_hex - \\t {#}] ])\\x{100}/",
623 "/(?[ [ $B_hex - C ] ])/" => "Ranges of ASCII printables should be some subset of \"0-9\", \"A-Z\", or \"a-z\" {#} m/(?[ [ $B_hex - C {#}] ])/",
624 "/(?[ [ A - $B_hex ] ])/" => "Ranges of ASCII printables should be some subset of \"0-9\", \"A-Z\", or \"a-z\" {#} m/(?[ [ A - $B_hex {#}] ])/",
625 "/(?[ [ $low_mixed_alpha - $high_mixed_alpha ] ])/" => "Ranges of ASCII printables should be some subset of \"0-9\", \"A-Z\", or \"a-z\" {#} m/(?[ [ $low_mixed_alpha - $high_mixed_alpha {#}] ])/",
626 "/(?[ [ $low_mixed_digit - $high_mixed_digit ] ])/" => "Ranges of ASCII printables should be some subset of \"0-9\", \"A-Z\", or \"a-z\" {#} m/(?[ [ $low_mixed_digit - $high_mixed_digit {#}] ])/",
629 '/[:blank]\x{100}/' => 'POSIX syntax [: :] belongs inside character classes (but this one isn\'t fully valid) {#} m/[:blank{#}]\x{100}/',
630 '/[[:digit]]\x{100}/' => 'Assuming NOT a POSIX class since there is no terminating \':\' {#} m/[[:digit{#}]]\x{100}/', # [perl # 8904]
631 '/[[:digit:foo]\x{100}/' => 'Assuming NOT a POSIX class since there is no terminating \']\' {#} m/[[:digit:{#}foo]\x{100}/',
632 '/[[:di#it:foo]\x{100}/x' => 'Assuming NOT a POSIX class since there is no terminating \']\' {#} m/[[:di#it:{#}foo]\x{100}/',
633 '/[[:dgit]]\x{100}/' => 'Assuming NOT a POSIX class since there is no terminating \':\' {#} m/[[:dgit{#}]]\x{100}/',
634 '/[[:dgit:foo]\x{100}/' => 'Assuming NOT a POSIX class since there is no terminating \']\' {#} m/[[:dgit:{#}foo]\x{100}/',
635 '/[[:dgt]]\x{100}/' => "", # Far enough away from a real class to not be recognized as one
636 '/[[:dgt:foo]\x{100}/' => "",
637 '/[[:DIGIT]]\x{100}/' => [ 'Assuming NOT a POSIX class since the name must be all lowercase letters {#} m/[[:DIGIT{#}]]\x{100}/',
638 'Assuming NOT a POSIX class since there is no terminating \':\' {#} m/[[:DIGIT{#}]]\x{100}/',
640 '/[[digit]\x{100}/' => [ 'Assuming NOT a POSIX class since there must be a starting \':\' {#} m/[[{#}digit]\x{100}/',
641 'Assuming NOT a POSIX class since there is no terminating \':\' {#} m/[[digit{#}]\x{100}/',
643 '/[[alpha]]\x{100}/' => [ 'Assuming NOT a POSIX class since there must be a starting \':\' {#} m/[[{#}alpha]]\x{100}/',
644 'Assuming NOT a POSIX class since there is no terminating \':\' {#} m/[[alpha{#}]]\x{100}/',
646 '/[[^word]\x{100}/' => [ 'Assuming NOT a POSIX class since the \'^\' must come after the colon {#} m/[[^{#}word]\x{100}/',
647 'Assuming NOT a POSIX class since there must be a starting \':\' {#} m/[[^{#}word]\x{100}/',
648 'Assuming NOT a POSIX class since there is no terminating \':\' {#} m/[[^word{#}]\x{100}/',
650 '/[[ ^ : x d i g i t : ] ]\x{100}/' => [ 'Assuming NOT a POSIX class since no blanks are allowed in one {#} m/[[ {#}^ : x d i g i t : ] ]\x{100}/',
651 'Assuming NOT a POSIX class since the \'^\' must come after the colon {#} m/[[ ^{#} : x d i g i t : ] ]\x{100}/',
652 'Assuming NOT a POSIX class since no blanks are allowed in one {#} m/[[ ^ {#}: x d i g i t : ] ]\x{100}/',
653 'Assuming NOT a POSIX class since no blanks are allowed in one {#} m/[[ ^ : {#}x d i g i t : ] ]\x{100}/',
654 'Assuming NOT a POSIX class since no blanks are allowed in one {#} m/[[ ^ : x d i g i t : ]{#} ]\x{100}/',
655 $only_strict_marker . 'Unescaped literal \']\' {#} m/[[ ^ : x d i g i t : ] ]{#}\x{100}/',
657 '/[foo:lower:]]\x{100}/' => 'Assuming NOT a POSIX class since it doesn\'t start with a \'[\' {#} m/[foo{#}:lower:]]\x{100}/',
658 '/[[;upper;]]\x{100}/' => [ 'Assuming NOT a POSIX class since a semi-colon was found instead of a colon {#} m/[[;{#}upper;]]\x{100}/',
659 'Assuming NOT a POSIX class since a semi-colon was found instead of a colon {#} m/[[;upper;]{#}]\x{100}/',
661 '/[foo;punct;]]\x{100}/' => [ 'Assuming NOT a POSIX class since it doesn\'t start with a \'[\' {#} m/[foo{#};punct;]]\x{100}/',
662 'Assuming NOT a POSIX class since a semi-colon was found instead of a colon {#} m/[foo;{#}punct;]]\x{100}/',
663 'Assuming NOT a POSIX class since a semi-colon was found instead of a colon {#} m/[foo;punct;]{#}]\x{100}/',
665 '/[][[:alpha:]]/' => "", # [perl #127581]
666 '/[][[:alpha:]\\@\\\\^_?]/' => "", # [perl #131522]
667 '/(?[[:w:]])/' => "",
668 '/([.].*)[.]/' => "", # [perl #127582]
669 '/[.].*[.]/' => "", # [perl #127604]
671 '/(?xmsixp:abc)/' => "",
672 '/(?xmsixp)abc/' => "",
673 '/(?xxxx:abc)/' => "",
675 ); # See comments before this for why '\x{100}' is generally needed
677 # These need the character 'ネ' as a marker for mark_as_utf8()
678 my @warnings_utf8 = mark_as_utf8(
679 'm/ネ\b*ネ/' => '\b* matches null string many times {#} m/ネ\b*{#}ネ/',
680 '/(?=ネ)*/' => '(?=ネ)* matches null string many times {#} m/(?=ネ)*{#}/',
681 'm/ネ[:foo:]ネ/' => 'POSIX syntax [: :] belongs inside character classes (but this one isn\'t fully valid) {#} m/ネ[:foo:]{#}ネ/',
682 '/ネ(?c)ネ/' => 'Useless (?c) - use /gc modifier {#} m/ネ(?c{#})ネ/',
683 '/utf8 ネ (?ogc) ネ/' => [
684 'Useless (?o) - use /o modifier {#} m/utf8 ネ (?o{#}gc) ネ/',
685 'Useless (?g) - use /g modifier {#} m/utf8 ネ (?og{#}c) ネ/',
686 'Useless (?c) - use /gc modifier {#} m/utf8 ネ (?ogc{#}) ネ/',
689 '/ネ(?[[:ネ:]])ネ/' => "",
693 push @warning, @warnings_utf8;
695 my @warning_only_under_strict = (
696 '/[\N{U+00}-\x01]\x{100}/' => 'Both or neither range ends should be Unicode {#} m/[\N{U+00}-\x01{#}]\x{100}/',
697 '/[\x00-\N{SOH}]\x{100}/' => 'Both or neither range ends should be Unicode {#} m/[\x00-\N{U+01}{#}]\x{100}/',
698 '/[\N{DEL}-\o{377}]\x{100}/' => 'Both or neither range ends should be Unicode {#} m/[\N{U+7F}-\o{377}{#}]\x{100}/',
699 '/[\o{0}-\N{U+01}]\x{100}/' => 'Both or neither range ends should be Unicode {#} m/[\o{0}-\N{U+01}{#}]\x{100}/',
700 '/[\000-\N{U+01}]\x{100}/' => 'Both or neither range ends should be Unicode {#} m/[\000-\N{U+01}{#}]\x{100}/',
701 '/[\N{DEL}-\377]\x{100}/' => 'Both or neither range ends should be Unicode {#} m/[\N{U+7F}-\377{#}]\x{100}/',
702 '/[\N{U+00}-A]\x{100}/' => 'Ranges of ASCII printables should be some subset of "0-9", "A-Z", or "a-z" {#} m/[\N{U+00}-A{#}]\x{100}/',
703 '/[a-\N{U+FF}]\x{100}/' => 'Ranges of ASCII printables should be some subset of "0-9", "A-Z", or "a-z" {#} m/[a-\N{U+FF}{#}]\x{100}/',
704 '/[\N{U+00}-\a]\x{100}/' => "",
705 '/[\a-\N{U+FF}]\x{100}/' => "",
706 '/[\N{U+100}-\x{101}]/' => "",
708 "/[:-\\x$colon_hex]\\x{100}/" => "\":-\\x$colon_hex\" is more clearly written simply as \":\" {#} m/[:-\\x$colon_hex\{#}]\\x{100}/",
709 "/[\\x$colon_hex-:]\\x{100}/" => "\"\\x$colon_hex-:\" is more clearly written simply as \":\" {#} m/[\\x$colon_hex\-:{#}]\\x{100}/",
710 "/[\\t-\\x$tab_hex]\\x{100}/" => "\"\\t-\\x$tab_hex\" is more clearly written simply as \"\\t\" {#} m/[\\t-\\x$tab_hex\{#}]\\x{100}/",
711 "/[\\x$tab_hex-\\t]\\x{100}/" => "\"\\x$tab_hex-\\t\" is more clearly written simply as \"\\t\" {#} m/[\\x$tab_hex\-\\t{#}]\\x{100}/",
712 "/[$B_hex-C]/" => "Ranges of ASCII printables should be some subset of \"0-9\", \"A-Z\", or \"a-z\" {#} m/[$B_hex-C{#}]/",
713 "/[A-$B_hex]/" => "Ranges of ASCII printables should be some subset of \"0-9\", \"A-Z\", or \"a-z\" {#} m/[A-$B_hex\{#}]/",
714 "/[$low_mixed_alpha-$high_mixed_alpha]/" => "Ranges of ASCII printables should be some subset of \"0-9\", \"A-Z\", or \"a-z\" {#} m/[$low_mixed_alpha-$high_mixed_alpha\{#}]/",
715 "/[$low_mixed_digit-$high_mixed_digit]/" => "Ranges of ASCII printables should be some subset of \"0-9\", \"A-Z\", or \"a-z\" {#} m/[$low_mixed_digit-$high_mixed_digit\{#}]/",
716 '/\b<GCB}/' => 'Unescaped literal \'}\' {#} m/\b<GCB}{#}/',
717 '/[ ]def]/' => 'Unescaped literal \']\' {#} m/[ ]def]{#}/',
718 '/(?)/' => 'Empty (?) without any modifiers {#} m/(?){#}/', # [perl #132851]
721 my @warning_utf8_only_under_strict = mark_as_utf8(
722 '/ネ[᪉-᪐]/; #no latin1' => "Ranges of digits should be from the same group of 10 {#} m/ネ[᪉-᪐{#}]/",
723 '/ネ(?[ [ ᪉ - ᪐ ] ])/; #no latin1' => "Ranges of digits should be from the same group of 10 {#} m/ネ(?[ [ ᪉ - ᪐ {#}] ])/",
724 '/ネ[᧙-᧚]/; #no latin1' => "Ranges of digits should be from the same group of 10 {#} m/ネ[᧙-᧚{#}]/",
725 '/ネ(?[ [ ᧙ - ᧚ ] ])/; #no latin1' => "Ranges of digits should be from the same group of 10 {#} m/ネ(?[ [ ᧙ - ᧚ {#}] ])/",
726 '/ネ(?[ [ 𝟘 - 𝟡 ] ])/; #no latin1' => "",
727 '/ネ(?[ [ 𝟧 - 𝟱 ] ])/; #no latin1' => "Ranges of digits should be from the same group of 10 {#} m/ネ(?[ [ 𝟧 - 𝟱 {#}] ])/",
728 '/ネ(?[ [ 𝟧 - 𝟰 ] ])/; #no latin1' => "Ranges of digits should be from the same group of 10 {#} m/ネ(?[ [ 𝟧 - 𝟰 {#}] ])/",
731 push @warning_only_under_strict, @warning_utf8_only_under_strict;
733 my @experimental_vlb = (
734 '/(?<=(p|qq|rrr))/' => 'Variable length positive lookbehind with capturing' .
735 ' is experimental {#} m/(?<=(p|qq|rrr)){#}/',
736 '/(?<!(p|qq|rrr))/' => 'Variable length negative lookbehind with capturing' .
737 ' is experimental {#} m/(?<!(p|qq|rrr)){#}/',
738 '/(?| (?=(foo)) | (?<=(foo)|p) )/'
739 => 'Variable length positive lookbehind with capturing' .
740 ' is experimental {#} m/(?| (?=(foo)) | (?<=(foo)|p) ){#}/',
741 '/(?| (?=(foo)) | (?<=(foo)|p) )/x'
742 => 'Variable length positive lookbehind with capturing' .
743 ' is experimental {#} m/(?| (?=(foo)) | (?<=(foo)|p) ){#}/',
744 '/(?| (?=(foo)) | (?<!(foo)|p) )/'
745 => 'Variable length negative lookbehind with capturing' .
746 ' is experimental {#} m/(?| (?=(foo)) | (?<!(foo)|p) ){#}/',
747 '/(?| (?=(foo)) | (?<!(foo)|p) )/x'
748 => 'Variable length negative lookbehind with capturing' .
749 ' is experimental {#} m/(?| (?=(foo)) | (?<!(foo)|p) ){#}/',
750 '/(?<!(foo|bop(*ACCEPT)|bar)baz)/'
751 => 'Variable length negative lookbehind with capturing' .
752 ' is experimental {#} m/(?<!(foo|bop(*ACCEPT)|bar)baz){#}/',
753 '/(?<=(foo|bop(*ACCEPT)|bar)baz)/'
754 => 'Variable length positive lookbehind with capturing' .
755 ' is experimental {#} m/(?<=(foo|bop(*ACCEPT)|bar)baz){#}/',
759 'm!(?[\p{name=/KATAKANA/}])$!' =>
761 'The Unicode property wildcards feature is experimental',
762 'Using just the single character results returned by \p{} in (?[...]) {#} m/(?[\p{name=/KATAKANA/}{#}])$/'
763 ], # [GH #17732] Null pointer deref
770 '/foo(:?{bar)/' => "",
775 for my $strict ("", "use re 'strict';") {
777 # First time just use @death; but under strict we add the things that fail
778 # there. Doing it this way makes sure that 'strict' doesnt change the
779 # things that are already fatal when not under strict.
781 for (my $i = 0; $i < @death_only_under_strict; $i += 3) {
782 push @death, $death_only_under_strict[$i], # The regex
783 $death_only_under_strict[$i+2]; # The fatal msg
785 for (my $i = 0; $i < @death_utf8_only_under_strict; $i += 3) {
787 # Same with the utf8 versions
788 push @death, mark_as_utf8($death_utf8_only_under_strict[$i],
789 $death_utf8_only_under_strict[$i+2]);
792 for (my $i = 0; $i < @death; $i += 2) {
793 my $regex = $death[$i] =~ s/ default_ (on | off) //rx;
794 my $expect = fixup_expect($death[$i+1], $strict);
796 fail("$0: Internal error: '$death[$i]' should have an error message");
799 no warnings 'experimental::re_strict';
800 no warnings 'experimental::uniprop_wildcards';
804 my $eval_string = "$strict $regex";
806 eval "$eval_string; \$meaning_of_life = 42";
807 ok (! defined $meaning_of_life, "$eval_string died");
809 if ($error =~ qr/\Q$expect/) {
810 ok(1, "... and gave expected message");
813 diag("Have: " . _q(add_markers($error)));
814 diag("Want: " . _q($death[$i+1]));
816 }, undef, "... and no other warnings");
821 for my $strict ("", "no warnings 'experimental::re_strict'; use re 'strict';") {
822 my @warning_tests = @warning;
824 # Build the tests for @warning. Use the strict/non-strict versions
827 push @warning_tests, @warning_only_under_strict;
830 for (my $i = 0; $i < @warning_only_under_strict; $i += 2) {
832 # (?[ ]) are always under strict
833 if ($warning_only_under_strict[$i] =~ /\Q(?[/) {
834 push @warning_tests, $warning_only_under_strict[$i], # The regex
835 $warning_only_under_strict[$i+1];
838 push @warning_tests, $warning_only_under_strict[$i], # The regex
839 ""; # No warning because not strict
842 for (my $i = 0; $i < @death_only_under_strict; $i += 3) {
843 push @warning_tests, $death_only_under_strict[$i], # The regex
844 $death_only_under_strict[$i+1]; # The warning
846 for (my $i = 0; $i < @death_utf8_only_under_strict; $i += 3) {
847 push @warning_tests, mark_as_utf8($death_utf8_only_under_strict[$i],
848 $death_utf8_only_under_strict[$i+1]);
860 if ($ref == \@warning_tests) {
861 $warning_type = 'regexp, digit';
862 $default_on = $strict;
864 elsif ($ref == \@deprecated) {
865 $warning_type = 'regexp, deprecated';
868 elsif ($ref == \@wildcard) {
869 $warning_type = 'experimental::uniprop_wildcards';
872 elsif ($ref == \@experimental_vlb) {
873 $warning_type = 'experimental::vlb';
877 fail("$0: Internal error: Unexpected loop variable");
880 for (my $i = 0; $i < @$ref; $i += 2) {
881 my $this_default_on = $default_on;
882 my $regex = $ref->[$i];
883 if ($regex =~ s/ default_ (on | off) //x) {
884 $this_default_on = $1 eq 'on';
886 my @expect = fixup_expect($ref->[$i+1], $strict);
888 # A length-1 array with an empty warning means no warning gets
890 undef @expect if @expect == 1 && $expect[0] eq "";
894 #use feature 'unicode_eval';
895 #print STDERR __LINE__, ": ", "eval '$strict no warnings; $regex'", "\n";
896 eval "$strict no warnings; $regex";
898 if (is($@, "", "$strict $regex did not die")) {
899 my @got = capture_warnings(sub {
901 eval "$strict $regex" });
903 if (! is(scalar @got, scalar @expect,
904 "... and gave expected number ($count) of warnings"))
906 if (@got < @expect) {
908 note "Expected warnings not gotten:\n\t" . join "\n\t",
909 @expect[$count .. $#expect];
912 note "Unexpected warnings gotten:\n\t" . join("\n\t",
913 @got[$count .. $#got]);
916 foreach my $i (0 .. $count - 1) {
917 if (! like($got[$i], qr/\Q$expect[$i]/,
918 "... and gave expected warning"))
922 diag("GOT\n'$got[$i]'\nEXPECT\n'$expect[$i]'");
925 # Turning off this type of warning should make the
926 # count go down by at least 1.
927 ok ($count - 1 >= capture_warnings(sub {
929 eval "$strict no warnings '$warning_type'; $regex;" }
931 "... and turning off '$warning_type' warnings suppressed it");
933 # Test that whether the warning is on by default is
934 # correct. This test relies on the fact that we
935 # are outside the scope of any ‘use warnings’.
937 my @warns = capture_warnings(sub {
939 eval "$strict $regex"
941 # Warning should be on as well if is testing
942 # '(?[...])' which turns on strict
943 if ( $this_default_on
944 || ( grep { $_ =~ /\Q(?[/ } @expect
945 and $ref != \@warning_tests))
947 ok @warns > 0, "... and the warning is on by default";
949 elsif (! (ok @warns == 0,
950 "... and the warning is off by default"))
952 diag("GOT\n" . join "\n", @warns);