This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Require closing paren for (?&...
authorFather Chrysostomos <sprout@cpan.org>
Mon, 18 Nov 2013 13:45:19 +0000 (05:45 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 18 Nov 2013 16:29:32 +0000 (08:29 -0800)
$ ./perl -Ilib -le 'print "aaz" =~ /(?<a>a)(?&a-z/'
a

(?&name) was actually allowing any non-word character to terminate it.

pod/perldiag.pod
regcomp.c
t/re/reg_mesg.t

index bdf8c55..7c0d8d4 100644 (file)
@@ -4776,6 +4776,13 @@ causes, see L<perlre>.
 parenthesis.  Embedded parentheses aren't allowed.  See
 L<perlre>.
 
+=item Sequence (?&... not terminated in regex; marked by S<<-- HERE> in
+m/%s/
+
+(F) A named reference of the form C<(?&...)> was missing the final
+closing parenthesis after the name.  The S<<-- HERE> shows whereabouts
+in the regular expression the problem was discovered.
+
 =item Sequence (?%c... not terminated in regex; marked by S<<-- HERE>
 in m/%s/
 
index 1b3c04d..7df5767 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -9350,6 +9350,8 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp,U32 depth)
                        SIZE_ONLY ? REG_RSN_RETURN_NULL : REG_RSN_RETURN_DATA);
                     num = sv_dat ? *((I32 *)SvPVX(sv_dat)) : 0;
                 }
+                if (RExC_parse == RExC_end || *RExC_parse != ')')
+                    vFAIL("Sequence (?&... not terminated");
                 goto gen_recurse_regop;
                 assert(0); /* NOT REACHED */
             case '+':
index 0835ce7..f81d8b6 100644 (file)
@@ -212,7 +212,8 @@ my @death =
  'm/\87/' => 'Reference to nonexistent group {#} m/\87{#}/',
  'm/a\87/' => 'Reference to nonexistent group {#} m/a\87{#}/',
  'm/a\97/' => 'Reference to nonexistent group {#} m/a\97{#}/',
- 'm/(*DOOF)/' => 'Unknown verb pattern \'DOOF\' {#} m/(*DOOF){#}/'
+ 'm/(*DOOF)/' => 'Unknown verb pattern \'DOOF\' {#} m/(*DOOF){#}/',
+ 'm/(?&a/'  => 'Sequence (?&... not terminated {#} m/(?&a{#}/',
 );
 
 my @death_utf8 = mark_as_utf8(