This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perldiag: Update descr for ‘Switch condition not recognized’
authorFather Chrysostomos <sprout@cpan.org>
Tue, 19 Nov 2013 05:30:45 +0000 (21:30 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Tue, 19 Nov 2013 21:00:53 +0000 (13:00 -0800)
Originally, the message ‘Switch (?(number%c not recognized’ only
applied to /(?(1junk))/.  perl-5.6.0-657-gb45f050 changed it to read
‘Switch condition not recognized’.

perl-5.8.0-8771-g0a4db38 added (?(<...>)), (?('...')), (?(DEFINE)) and
(?(R...)).  All of these can trigger that messages if there is junk
before the first closing parenthesis (e.g., /(?(<name>junk))/, causing
a mismatch between the cases where the error occurs and the descrip-
tion in perldiag:

    (F) If the argument to the (?(...)if-clause|else-clause) con-
    struct is a number, it can be only a number.  The <-- HERE shows
    whereabouts in the regular expression the problem was discovered.
    See perlre.

(which itself was already confusingly worded).

Whether these should be changed to use the more standard ‘Unknown
switch condition’ message I don’t want to deal with right now.

In any case, the description is only sometimes relevant, so this com-
mit just copies the description from ‘Unknown switch condition’.

pod/perldiag.pod

index c785e95..773c43b 100644 (file)
@@ -5111,9 +5111,21 @@ was discovered.  See L<perlre>.
 =item Switch condition not recognized in regex; marked by S<<-- HERE> in
 m/%s/
 
-(F) If the argument to the (?(...)if-clause|else-clause) construct is
-a number, it can be only a number.  The S<<-- HERE> shows whereabouts in
-the regular expression the problem was discovered.  See L<perlre>.
+(F) The condition part of a (?(condition)if-clause|else-clause) construct
+is not known.  The condition must be one of the following:
+
+ (1) (2) ...        true if 1st, 2nd, etc., capture matched
+ (<NAME>) ('NAME')  true if named capture matched
+ (?=...) (?<=...)   true if subpattern matches
+ (?!...) (?<!...)   true if subpattern fails to match
+ (?{ CODE })        true if code returns a true value
+ (R)                true if evaluating inside recursion
+ (R1) (R2) ...      true if directly inside capture group 1, 2, etc.
+ (R&NAME)           true if directly inside named capture
+ (DEFINE)           always false; for defining named subpatterns
+
+The <-- HERE shows whereabouts in the regular expression the problem was
+discovered.  See L<perlre>.
 
 =item switching effective %s is not implemented