return @ret;
}
-my $inf_m1 = ($Config::Config{reg_infty} || 32767) - 1;
+my $inf_m1 = ($Config::Config{reg_infty} || 65535) - 1;
my $inf_p1 = $inf_m1 + 2;
my $B_hex = sprintf("\\x%02X", ord "B");
#
# The first set are those that should be fatal errors.
+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";
+
my @death =
(
'/[[=foo=]]/' => 'POSIX syntax [= =] is reserved for future extensions {#} m/[[=foo=]{#}]/',
- '/(?<= .*)/' => 'Variable length lookbehind not implemented in regex m/(?<= .*)/',
+ '/(?<= .*)/' => 'Lookbehind longer than 255 not implemented in regex m/(?<= .*)/',
'/(?<= x{1000})/' => 'Lookbehind longer than 255 not implemented in regex m/(?<= x{1000})/',
'/\b{gc}/' => "'gc' is an unknown bound type {#} m/\\b{gc{#}}/",
'/\B{gc}/' => "'gc' is an unknown bound type {#} m/\\B{gc{#}}/",
-
'/(?[[[::]]])/' => "Unexpected ']' with no following ')' in (?[... {#} m/(?[[[::]]{#}])/",
'/(?[[[:w:]]])/' => "Unexpected ']' with no following ')' in (?[... {#} m/(?[[[:w:]]{#}])/",
- '/(?[[:w:]])/' => "",
- '/([.].*)[.]/' => "", # [perl #127582]
- '/[.].*[.]/' => "", # [perl #127604]
'/(?[a])/' => 'Unexpected character {#} m/(?[a{#}])/',
'/(?[ + \t ])/' => 'Unexpected binary operator \'+\' with no preceding operand {#} m/(?[ +{#} \t ])/',
'/(?[ \cK - ( + \t ) ])/' => 'Unexpected binary operator \'+\' with no preceding operand {#} m/(?[ \cK - ( +{#} \t ) ])/',
'/(?[ \0004 ])/' => 'Need exactly 3 octal digits {#} m/(?[ \0004 {#}])/',
'/(?[ \05 ])/' => 'Need exactly 3 octal digits {#} m/(?[ \05 {#}])/',
'/(?[ \o{1038} ])/' => 'Non-octal character {#} m/(?[ \o{1038{#}} ])/',
- '/(?[ \o{} ])/' => 'Number with no digits {#} m/(?[ \o{}{#} ])/',
+ '/(?[ \o{} ])/' => 'Empty \o{} {#} m/(?[ \o{}{#} ])/',
'/(?[ \x{defg} ])/' => 'Non-hex character {#} m/(?[ \x{defg{#}} ])/',
'/(?[ \xabcdef ])/' => 'Use \\x{...} for more than two hex characters {#} m/(?[ \xabc{#}def ])/',
- '/(?[ \x{} ])/' => 'Number with no digits {#} m/(?[ \x{}{#} ])/',
+ '/(?[ \x{} ])/' => 'Empty \x{} {#} m/(?[ \x{}{#} ])/',
'/(?[ \cK + ) ])/' => 'Unexpected \')\' {#} m/(?[ \cK + ){#} ])/',
'/(?[ \cK + ])/' => 'Incomplete expression within \'(?[ ])\' {#} m/(?[ \cK + {#}])/',
'/(?[ ( ) ])/' => 'Incomplete expression within \'(?[ ])\' {#} m/(?[ ( ){#} ])/',
'm/(?[[a-\pM]])/' => 'False [] range "a-\pM" {#} m/(?[[a-\pM{#}]])/',
'm/(?[[\pM-x]])/' => 'False [] range "\pM-" {#} m/(?[[\pM-{#}x]])/',
'm/(?[[^\N{LATIN CAPITAL LETTER A WITH MACRON AND GRAVE}]])/' => '\N{} in inverted character class or as a range end-point is restricted to one character {#} m/(?[[^\N{U+100.300{#}}]])/',
- 'm/(?[ \p{Digit} & (?(?[ \p{Thai} | \p{Lao} ]))])/' => 'Sequence (?(...) not recognized {#} m/(?[ \p{Digit} & (?({#}?[ \p{Thai} | \p{Lao} ]))])/',
- 'm/(?[ \p{Digit} & (?:(?[ \p{Thai} | \p{Lao} ]))])/' => 'Expecting \'(?flags:(?[...\' {#} m/(?[ \p{Digit} & (?{#}:(?[ \p{Thai} | \p{Lao} ]))])/',
+ 'm/(?[ \p{Digit} & (?^(?[ \p{Thai} | \p{Lao} ]))])/' => 'Sequence (?^(...) not recognized {#} m/(?[ \p{Digit} & (?^({#}?[ \p{Thai} | \p{Lao} ]))])/',
+ 'm/(?[ \p{Digit} & (?(?[ \p{Thai} | \p{Lao} ]))])/' => 'Unexpected character {#} m/(?[ \p{Digit} & (?{#}(?[ \p{Thai} | \p{Lao} ]))])/',
'm/\o{/' => 'Missing right brace on \o{ {#} m/\o{{#}/',
'm/\o/' => 'Missing braces on \o{} {#} m/\o{#}/',
- 'm/\o{}/' => 'Number with no digits {#} m/\o{}{#}/',
+ 'm/\o{}/' => 'Empty \o{} {#} m/\o{}{#}/',
'm/[\o{]/' => 'Missing right brace on \o{ {#} m/[\o{{#}]/',
'm/[\o]/' => 'Missing braces on \o{} {#} m/[\o{#}]/',
- 'm/[\o{}]/' => 'Number with no digits {#} m/[\o{}{#}]/',
+ 'm/[\o{}]/' => 'Empty \o{} {#} m/[\o{}{#}]/',
'm/(?^-i:foo)/' => 'Sequence (?^-...) not recognized {#} m/(?^-{#}i:foo)/',
'm/\87/' => 'Reference to nonexistent group {#} m/\87{#}/',
'm/a\87/' => 'Reference to nonexistent group {#} m/a\87{#}/',
'm/\cß/' => "Character following \"\\c\" must be printable ASCII",
'/((?# 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)/',
'/((?# 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)/',
+ '/((?# 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)/',
+
+ '/(*script_runfoo)/' => 'Unknown \'(*...)\' construct \'script_runfoo\' {#} m/(*script_runfoo){#}/',
+ '/(*srfoo)/' => 'Unknown \'(*...)\' construct \'srfoo\' {#} m/(*srfoo){#}/',
+ '/(*script_run)/' => '\'(*script_run\' requires a terminating \':\' {#} m/(*script_run{#})/',
+ '/(*sr)/' => '\'(*sr\' requires a terminating \':\' {#} m/(*sr{#})/',
+ '/(*pla)/' => '\'(*pla\' requires a terminating \':\' {#} m/(*pla{#})/',
+ '/(*script_run/' => 'Unterminated \'(*...\' construct {#} m/(*script_run{#}/',
+ '/(*sr/' => 'Unterminated \'(*...\' construct {#} m/(*sr{#}/',
+ '/(*script_run:foo/' => 'Unterminated \'(*...\' argument {#} m/(*script_run:foo{#}/',
+ '/(*sr:foo/' => 'Unterminated \'(*...\' argument {#} m/(*sr:foo{#}/',
'/(?[\ &!])/' => 'Incomplete expression within \'(?[ ])\' {#} m/(?[\ &!{#}])/', # [perl #126180]
'/(?[\ +!])/' => 'Incomplete expression within \'(?[ ])\' {#} m/(?[\ +!{#}])/', # [perl #126180]
'/(?[\ -!])/' => 'Incomplete expression within \'(?[ ])\' {#} m/(?[\ -!{#}])/', # [perl #126180]
'/\w{/' => 'Unescaped left brace in regex is illegal here {#} m/\w{{#}/',
'/\q{/' => 'Unescaped left brace in regex is illegal here {#} m/\q{{#}/',
'/\A{/' => 'Unescaped left brace in regex is illegal here {#} m/\A{{#}/',
- '/abc/xix' => "",
- '/(?xmsixp:abc)/' => "",
- '/(?xmsixp)abc/' => "",
- '/(?xxxx:abc)/' => "",
+ '/.{, 4 }/' => 'Unescaped left brace in regex is illegal here {#} m/.{{#}, 4 }/',
+ '/[x]{, 4}/' => 'Unescaped left brace in regex is illegal here {#} m/[x]{{#}, 4}/',
+ '/\p{Latin}{,4 }/' => 'Unescaped left brace in regex is illegal here {#} m/\p{Latin}{{#},4 }/',
'/(?<=/' => 'Sequence (?... not terminated {#} m/(?<={#}/', # [perl #128170]
-
+ '/\p{vertical \v tab}/' => 'Can\'t find Unicode property definition "vertical \v tab" {#} m/\\p{vertical \v tab}{#}/', # [perl #132055]
+ "/$bug133423/" => "Operand with no preceding operator {#} 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/",
+ '/[^/' => 'Unmatched [ {#} m/[{#}^/', # [perl #133767]
+ '/\p{Is_Other_Alphabetic=F}/ ' => 'Can\'t find Unicode property definition "Is_Other_Alphabetic=F" {#} m/\p{Is_Other_Alphabetic=F}{#}/',
+ '/\p{Is_Other_Alphabetic=F}/ ' => 'Can\'t find Unicode property definition "Is_Other_Alphabetic=F" {#} m/\p{Is_Other_Alphabetic=F}{#}/',
);
# These are messages that are death under 'use re "strict"', and may or may
'm/[\o{789}]/' => 'Non-octal character \'8\'. Resolved as "\o{7}"',
=> 'Non-octal character {#} m/[\o{78{#}9}]/',
'm/\x{}/' => "",
- => 'Number with no digits {#} m/\x{}{#}/',
+ => 'Empty \x{} {#} m/\x{}{#}/',
'm/[\x{}]/' => "",
- => 'Number with no digits {#} m/[\x{}{#}]/',
+ => 'Empty \x{} {#} m/[\x{}{#}]/',
'm/\x{ABCDEFG}/' => 'Illegal hexadecimal digit \'G\' ignored',
=> 'Non-hex character {#} m/\x{ABCDEFG{#}}/',
'm/[\x{ABCDEFG}]/' => 'Illegal hexadecimal digit \'G\' ignored',
=> 'False [] range "[:digit:]-" {#} m/[[:digit:]-{#}[:alpha:]]\x{100}/',
'/[a\zb]\x{100}/' => 'Unrecognized escape \z in character class passed through {#} m/[a\z{#}b]\x{100}/',
=> 'Unrecognized escape \z in character class {#} m/[a\z{#}b]\x{100}/',
- 'default_on/:{4,a}/' => 'Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.30), passed through {#} m/:{{#}4,a}/',
- => 'Unescaped left brace in regex is illegal here {#} m/:{{#}4,a}/',
- 'default_on/xa{3\,4}y/' => 'Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.30), passed through {#} m/xa{{#}3\,4}y/',
- => 'Unescaped left brace in regex is illegal here {#} m/xa{{#}3\,4}y/',
- 'default_on/\\${[^\\}]*}/' => 'Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.30), passed through {#} m/\\${{#}[^\\}]*}/',
- => 'Unescaped left brace in regex is illegal here {#} m/\\${{#}[^\\}]*}/',
'/[a\fb]/' => "",
=> 'Literal vertical space in [] is illegal except under /x {#} m/[a\f{#}b]/',
+ '/:{4,a}/' => 'Unescaped left brace in regex is passed through {#} m/:{{#}4,a}/',
+ => 'Unescaped left brace in regex is illegal here {#} m/:{{#}4,a}/',
+ '/xa{3\,4}y/' => 'Unescaped left brace in regex is passed through {#} m/xa{{#}3\,4}y/',
+ => 'Unescaped left brace in regex is illegal here {#} m/xa{{#}3\,4}y/',
+ '/\\${[^\\}]*}/' => 'Unescaped left brace in regex is passed through {#} m/\\${{#}[^\\}]*}/',
+ => 'Unescaped left brace in regex is illegal here {#} m/\\${{#}[^\\}]*}/',
+ '/.{/' => 'Unescaped left brace in regex is passed through {#} m/.{{#}/',
+ => 'Unescaped left brace in regex is illegal here {#} m/.{{#}/',
+ '/[x]{/' => 'Unescaped left brace in regex is passed through {#} m/[x]{{#}/',
+ => 'Unescaped left brace in regex is illegal here {#} m/[x]{{#}/',
+ '/\p{Latin}{/' => 'Unescaped left brace in regex is passed through {#} m/\p{Latin}{{#}/',
+ => 'Unescaped left brace in regex is illegal here {#} m/\p{Latin}{{#}/',
+ '/\x{100}\x/' => "",
+ => "Empty \\x {#} m/\\x{100}\\x{#}/",
);
# These need the character 'ネ' as a marker for mark_as_utf8()
my @death_utf8 = mark_as_utf8(
- '/ネ(?<= .*)/' => 'Variable length lookbehind not implemented in regex m/ネ(?<= .*)/',
+ '/ネ(?<= .*)/' => 'Lookbehind longer than 255 not implemented in regex m/ネ(?<= .*)/',
'/(?<= ネ{1000})/' => 'Lookbehind longer than 255 not implemented in regex m/(?<= ネ{1000})/',
'/ネ[\x{ネ]/' => 'Missing right brace on \x{} {#} m/ネ[\x{{#}ネ]/',
'/ネ\o{ネ/' => 'Missing right brace on \o{ {#} m/ネ\o{{#}ネ/',
- '/ネ[[:ネ:]]ネ/' => "",
'/[ネ-a]ネ/' => 'Invalid [] range "ネ-a" {#} m/[ネ-a{#}]ネ/',
'/ネ(?[[[:ネ: ])ネ/' => "Syntax error in (?[...]) {#} m/ネ(?[[[:ネ: ])ネ{#}/",
'/ネ(?[[[::]]])ネ/' => "Unexpected ']' with no following ')' in (?[... {#} m/ネ(?[[[::]]{#}])ネ/",
'/ネ(?[[[:ネ:]]])ネ/' => "Unexpected ']' with no following ')' in (?[... {#} m/ネ(?[[[:ネ:]]{#}])ネ/",
- '/ネ(?[[:ネ:]])ネ/' => "",
'/ネ(?[ネ])ネ/' => 'Unexpected character {#} m/ネ(?[ネ{#}])ネ/',
'/ネ(?[ + [ネ] ])/' => 'Unexpected binary operator \'+\' with no preceding operand {#} m/ネ(?[ +{#} [ネ] ])/',
'/ネ(?[ \cK - ( + [ネ] ) ])/' => 'Unexpected binary operator \'+\' with no preceding operand {#} m/ネ(?[ \cK - ( +{#} [ネ] ) ])/',
'/ネ(?[ \cK [ネ] ])ネ/' => 'Operand with no preceding operator {#} m/ネ(?[ \cK [ネ{#}] ])ネ/',
'/ネ(?[ \0004 ])ネ/' => 'Need exactly 3 octal digits {#} m/ネ(?[ \0004 {#}])ネ/',
'/(?[ \o{ネ} ])ネ/' => 'Non-octal character {#} m/(?[ \o{ネ{#}} ])ネ/',
- '/ネ(?[ \o{} ])ネ/' => 'Number with no digits {#} m/ネ(?[ \o{}{#} ])ネ/',
+ '/ネ(?[ \o{} ])ネ/' => 'Empty \o{} {#} m/ネ(?[ \o{}{#} ])ネ/',
'/(?[ \x{ネ} ])ネ/' => 'Non-hex character {#} m/(?[ \x{ネ{#}} ])ネ/',
'/(?[ \p{ネ} ])/' => 'Can\'t find Unicode property definition "ネ" {#} m/(?[ \p{ネ}{#} ])/',
'/(?[ \p{ ネ = bar } ])/' => 'Can\'t find Unicode property definition "ネ = bar" {#} m/(?[ \p{ ネ = bar }{#} ])/',
'/ネ(?[ \t ]/' => "Unexpected ']' with no following ')' in (?[... {#} m/ネ(?[ \\t ]{#}/",
'/(?[ \t + \e # ネ This was supposed to be a comment ])/' =>
"Syntax error in (?[...]) {#} m/(?[ \\t + \\e # ネ This was supposed to be a comment ]){#}/",
- 'm/(*ネ)ネ/' => q<Unknown verb pattern 'ネ' {#} m/(*ネ){#}ネ/>,
+ 'm/(*ネ)ネ/' => q<Unknown '(*...)' construct 'ネ' {#} m/(*ネ){#}ネ/>,
'/\cネ/' => "Character following \"\\c\" must be printable ASCII",
'/\b{ネ}/' => "'ネ' is an unknown bound type {#} m/\\b{ネ{#}}/",
'/\B{ネ}/' => "'ネ' is an unknown bound type {#} m/\\B{ネ{#}}/",
'/(?=a)*/' => '(?=a)* matches null string many times {#} m/(?=a)*{#}/',
'my $x = \'\m\'; qr/a$x/' => 'Unrecognized escape \m passed through {#} m/a\m{#}/',
'/\q/' => 'Unrecognized escape \q passed through {#} m/\q{#}/',
+ '/\q\p{Any}/' => 'Unrecognized escape \q passed through {#} m/\q{#}\p{Any}/',
# These two tests do not include the marker, because regcomp.c no
# longer knows where it goes by the time this warning is emitted.
],
'/[][[:alpha:]]/' => "", # [perl #127581]
'/[][[:alpha:]\\@\\\\^_?]/' => "", # [perl #131522]
+ '/(?[[:w:]])/' => "",
+ '/([.].*)[.]/' => "", # [perl #127582]
+ '/[.].*[.]/' => "", # [perl #127604]
+ '/abc/xix' => "",
+ '/(?xmsixp:abc)/' => "",
+ '/(?xmsixp)abc/' => "",
+ '/(?xxxx:abc)/' => "",
+
); # See comments before this for why '\x{100}' is generally needed
# These need the character 'ネ' as a marker for mark_as_utf8()
'Useless (?g) - use /g modifier {#} m/utf8 ネ (?og{#}c) ネ/',
'Useless (?c) - use /gc modifier {#} m/utf8 ネ (?ogc{#}) ネ/',
],
+ '/ネ[[:ネ:]]ネ/' => "",
+ '/ネ(?[[:ネ:]])ネ/' => "",
);
"/[$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\{#}]/",
'/\b<GCB}/' => 'Unescaped literal \'}\' {#} m/\b<GCB}{#}/',
'/[ ]def]/' => 'Unescaped literal \']\' {#} m/[ ]def]{#}/',
+ '/(?)/' => 'Empty (?) without any modifiers {#} m/(?){#}/', [perl #132851]
);
my @warning_utf8_only_under_strict = mark_as_utf8(
'/noutf8 ネ (?[ [\tネ] ])/' => 'The regex_sets feature is experimental {#} m/noutf8 ネ (?[{#} [\tネ] ])/',
);
+my @experimental_script_run = (
+ '/(*script_run:paypal.com)/' => 'The script_run feature is experimental {#} m/(*script_run:{#}paypal.com)/',
+ 'use utf8; /utf8 ネ (*script_run:ネ)/' => do { use utf8; 'The script_run feature is experimental {#} m/utf8 ネ (*script_run:{#}ネ)/' },
+ '/noutf8 ネ (*script_run:ネ)/' => 'The script_run feature is experimental {#} m/noutf8 ネ (*script_run:{#}ネ)/',
+);
+
my @deprecated = (
'/^{/' => "",
'/foo|{/' => "",
'/foo|^{/' => "",
- '/foo({bar)/' => "",
+ '/foo({bar)/' => 'Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.32), passed through {#} m/foo({{#}bar)/',
'/foo(:?{bar)/' => "",
'/\s*{/' => "",
'/a{3,4}{/' => "",
- '/.{/' => 'Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.30), passed through {#} m/.{{#}/',
- '/[x]{/' => 'Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.30), passed through {#} m/[x]{{#}/',
- '/\p{Latin}{/' => 'Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.30), passed through {#} m/\p{Latin}{{#}/',
);
for my $strict ("", "use re 'strict';") {
for (my $i = 0; $i < @death; $i += 2) {
my $regex = $death[$i] =~ s/ default_ (on | off) //rx;
my $expect = fixup_expect($death[$i+1], $strict);
- no warnings 'experimental::regex_sets';
- no warnings 'experimental::re_strict';
+ if ($expect eq "") {
+ fail("$0: Internal error: '$death[$i]' should have an error message");
+ }
+ else {
+ no warnings 'experimental::regex_sets';
+ no warnings 'experimental::script_run';
+ no warnings 'experimental::re_strict';
+ no warnings 'experimental::alpha_assertions';
- warning_is(sub {
+ warning_is(sub {
+ my $meaning_of_life;
my $eval_string = "$strict $regex";
$_ = "x";
- eval $eval_string;
+ eval "$eval_string; \$meaning_of_life = 42";
+ ok (! defined $meaning_of_life, "$eval_string died");
my $error= $@;
if ($error =~ qr/\Q$expect/) {
- ok(1,$eval_string);
+ ok(1, "... and gave expected message");
} else {
ok(0,$eval_string);
diag("Have: " . _q(add_markers($error)));
diag("Want: " . _q($death[$i+1]));
}
- }, undef, "... and died without any other warnings");
+ }, undef, "... and no other warnings");
+ }
}
}
}
}
- foreach my $ref (\@warning_tests, \@experimental_regex_sets, \@deprecated) {
+ foreach my $ref (\@warning_tests,
+ \@experimental_regex_sets,
+ \@experimental_script_run,
+ \@deprecated)
+ {
my $warning_type;
my $turn_off_warnings = "";
my $default_on;
if ($ref == \@warning_tests) {
$warning_type = 'regexp, digit';
- $turn_off_warnings = "no warnings 'experimental::regex_sets';";
+ $turn_off_warnings = "no warnings 'experimental::regex_sets';"
+ . "no warnings 'experimental::script_run';";
$default_on = $strict;
}
elsif ($ref == \@deprecated) {
$warning_type = 'regexp, deprecated';
$default_on = 1;
}
- else {
+ elsif ($ref == \@experimental_regex_sets) {
$warning_type = 'experimental::regex_sets';
$default_on = 1;
}
+ elsif ($ref == \@experimental_script_run) {
+ $warning_type = 'experimental::script_run';
+ $default_on = 1;
+ }
+ else {
+ fail("$0: Internal error: Unexpected loop variable");
+ }
+
for (my $i = 0; $i < @$ref; $i += 2) {
my $this_default_on = $default_on;
my $regex = $ref->[$i];