This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
remove invalid assertion in (??{}) return code
authorDavid Mitchell <davem@iabyn.com>
Sun, 3 Jun 2012 16:56:22 +0000 (17:56 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 13 Jun 2012 12:32:54 +0000 (13:32 +0100)
regexec.c
t/re/pat_re_eval.t

index 3e9cf21..0969379 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -4439,7 +4439,6 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog)
                            rx = (REGEXP*) sv;
                        } else if (SvSMAGICAL(sv)) {
                            mg = mg_find(sv, PERL_MAGIC_qr);
-                           assert(mg);
                        }
                    } else if (SvTYPE(ret) == SVt_REGEXP) {
                        rx = (REGEXP*) ret;
index 0c16f9e..89628ae 100644 (file)
@@ -23,7 +23,7 @@ BEGIN {
 }
 
 
-plan tests => 446;  # Update this when adding/deleting tests.
+plan tests => 447;  # Update this when adding/deleting tests.
 
 run_tests() unless caller;
 
@@ -946,6 +946,15 @@ sub run_tests {
        ok("AB1CD" =~ /^$A(??{$pat})D$/, "re eval propagated run-time");
     }
 
+    # returning a ref to something that had set magic but wasn't
+    # PERL_MAGIC_qr triggered a false positive assertion failure
+    # The test is not so much concerned with it not matching,
+    # as with not failing the assertion
+
+    {
+       ok("a" !~ /^(a)(??{ \$1 })/, '(??{ ref })');
+    }
+
 
 } # End of sub run_tests