This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove "ternary operator parsed as search pattern" warning
authorDagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Thu, 2 Jan 2014 13:06:51 +0000 (14:06 +0100)
committerMatthew Horsfall (alh) <wolfsage@gmail.com>
Tue, 17 Jun 2014 12:07:22 +0000 (08:07 -0400)
Since ?PATTERN? without 'm' is no longer supported, there is no
ambiguity any more.

pod/perldiag.pod
toke.c

index f5b93b5..ea9aab1 100644 (file)
@@ -4786,16 +4786,6 @@ construct, not just the empty search pattern.  Therefore code written
 in Perl 5.10.0 or later that uses the // as the I<defined-or> can be
 misparsed by pre-5.10.0 Perls as a non-terminated search pattern.
 
-=item Search pattern not terminated or ternary operator parsed as search pattern
-
-(F) The lexer couldn't find the final delimiter of a C<?PATTERN?>
-construct.
-
-The question mark is also used as part of the ternary operator (as in
-C<foo ? 0 : 1>) leading to some ambiguous constructions being wrongly
-parsed.  One way to disambiguate the parsing is to put parentheses around
-the conditional expression, i.e. C<(foo) ? 0 : 1>.
-
 =item seekdir() attempted on invalid dirhandle %s
 
 (W io) The dirhandle you are doing a seekdir() on is either closed or not
diff --git a/toke.c b/toke.c
index bf00793..44293de 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -8794,14 +8794,8 @@ S_scan_pat(pTHX_ char *start, I32 type)
     PERL_ARGS_ASSERT_SCAN_PAT;
 
     s = scan_str(start,TRUE,FALSE, (PL_in_eval & EVAL_RE_REPARSING), NULL);
-    if (!s) {
-       const char * const delimiter = skipspace(start);
-       Perl_croak(aTHX_
-                  (const char *)
-                  (*delimiter == '?'
-                   ? "Search pattern not terminated or ternary operator parsed as search pattern"
-                   : "Search pattern not terminated" ));
-    }
+    if (!s)
+       Perl_croak(aTHX_ "Search pattern not terminated");
 
     pm = (PMOP*)newPMOP(type, 0);
     if (PL_multi_open == '?') {