This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make \N{alias} deprecations fatal.
authorKarl Williamson <public@khwilliamson.com>
Fri, 26 Oct 2012 02:12:04 +0000 (20:12 -0600)
committerKarl Williamson <public@khwilliamson.com>
Sun, 11 Nov 2012 17:11:33 +0000 (10:11 -0700)
Since v5.12, using some non-name like characters, like commas, have
generated a deprecation warning.  The required 2 releases have been
made, and they are now being made fatal.

lib/charnames.pm
pod/perldelta.pod
pod/perldiag.pod
t/re/pat_advanced.t
toke.c

index 25c087d..0786690 100644 (file)
@@ -270,13 +270,9 @@ conventions.  The aliases override any standard definitions, so, if
 you're twisted enough, you can change C<"\N{LATIN CAPITAL LETTER A}"> to
 mean C<"B">, etc.
 
-Note that an alias should not be something that is a legal curly
-brace-enclosed quantifier (see L<perlreref/QUANTIFIERS>).  For example
-C<\N{123}> means to match 123 non-newline characters, and is not treated as a
-charnames alias.  Aliases are discouraged from beginning with anything
-other than an alphabetic character and from containing anything other
-than alphanumerics, spaces, dashes, parentheses, and underscores.
-Currently they must be Latin1.
+Aliases may not begin with anything other than an alphabetic character nor
+contain anything other than alphanumerics, spaces, dashes, parentheses, and
+underscores.  Currently they must be Latin1.
 
 An alias can map to either an official Unicode character name (not a loose
 matched name) or to a
index 0af6b40..26d808f 100644 (file)
@@ -54,6 +54,17 @@ behaviors, and since the REPLACEMENT CHARACTER has no use other than as
 a stand-in for some unknown character, any code that has this problem is
 buggy.
 
+=head2 Formerly deprecated characters in C<\N{}> character name aliases are now errors.
+
+Since v5.12.0, it has been deprecated to use certain characters in
+user-defined C<\N{...}> character names.  These now cause a syntax
+error.  For example, it is now an error to begin a name with a digit,
+such as in
+
+ my $undraftable = "\N{4F}";    # Syntax error!
+
+or to have commas anywhere in the name.  See L<charnames/CUSTOM ALIASES>
+
 =head1 Deprecations
 
 XXX Any deprecated features, syntax, modules etc. should be listed here.  In
index 3c3a48e..5cac1d1 100644 (file)
@@ -1636,14 +1636,6 @@ there are neither package declarations nor a C<$VERSION>.
 long for Perl to handle.  You have to be seriously twisted to write code
 that triggers this error.
 
-=item Deprecated character in \N{...}; marked by <-- HERE  in \N{%s<-- HERE %s
-
-(D deprecated) Just about anything is legal for the C<...> in C<\N{...}>.
-But starting in 5.12, non-reasonable ones that don't look like names
-are deprecated.  A reasonable name begins with an alphabetic character
-and continues with any combination of alphanumerics, dashes, spaces,
-parentheses or colons.
-
 =item Deprecated use of my() in false conditional
 
 (D deprecated) You used a declaration similar to C<my $x if 0>.  There
@@ -2368,6 +2360,11 @@ by Perl or by a user-supplied handler.  See L<attributes>.
 (F) The indicated attributes for a subroutine or variable were not
 recognized by Perl or by a user-supplied handler.  See L<attributes>.
 
+=item Invalid character in \N{...}; marked by <-- HERE in \N{%s}
+
+(F) Only certain characters are valid for character names.  The
+indicated one isn't.  See L<charnames/CUSTOM ALIASES>.
+
 =item Invalid conversion in %s: "%s"
 
 (W printf) Perl does not understand the given format conversion.  See
index 9502928..538c3ef 100644 (file)
@@ -1017,16 +1017,13 @@ sub run_tests {
         eval q [ok "\N{TOO-LONG-STR}" =~ /^\N{TOO-LONG-STR}$/, 'Verify that what once was too long a string works'];
         eval 'q(syntax error) =~ /\N{MALFORMED}/';
         ok $@ && $@ =~ /Malformed/, 'Verify that malformed utf8 gives an error';
-        undef $w;
         eval 'q() =~ /\N{4F}/';
-        ok $w && $w =~ /Deprecated/, 'Verify that leading digit in name gives warning';
-        undef $w;
+        ok $@ && $@ =~ /Invalid character/, 'Verify that leading digit in name gives error';
         eval 'q() =~ /\N{COM,MA}/';
-        ok $w && $w =~ /Deprecated/, 'Verify that comma in name gives warning';
-        undef $w;
+        ok $@ && $@ =~ /Invalid character/, 'Verify that comma in name gives error';
         my $name = "A\x{D7}O";
         eval "q(W) =~ /\\N{$name}/";
-        ok $w && $w =~ /Deprecated/, 'Verify that latin1 symbol in name gives warning';
+        ok $@ && $@ =~ /Invalid character/, 'Verify that latin1 symbol in name gives error';
         undef $w;
         $name = "A\x{D1}O";
         eval "q(W) =~ /\\N{$name}/";
diff --git a/toke.c b/toke.c
index f155107..b3c3767 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -2663,8 +2663,7 @@ S_get_and_check_backslash_N_name(pTHX_ const char* s, const char* const e)
         return NULL;
     }
 
-    /* Deprecate non-approved name syntax */
-    if (ckWARN_d(WARN_DEPRECATED)) {
+    {
         bool problematic = FALSE;
         const char* i = s;
 
@@ -2715,9 +2714,10 @@ S_get_and_check_backslash_N_name(pTHX_ const char* s, const char* const e)
             /* The e-i passed to the final %.*s makes sure that should the
              * trailing NUL be missing that this print won't run off the end of
              * the string */
-            Perl_warner(aTHX_ packWARN(WARN_DEPRECATED),
-                        "Deprecated character in \\N{...}; marked by <-- HERE  in \\N{%.*s<-- HERE %.*s",
-                        (int)(i - s + 1), s, (int)(e - i), i + 1);
+            yyerror(Perl_form(aTHX_
+                        "Invalid character in \\N{...}; marked by <-- HERE in \\N{%.*s<-- HERE %.*s",
+                        (int)(i - s + 1), s, (int)(e - i), i + 1));
+            return NULL;
         }
     }