This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix comments and pod that mention 5.20 erroneously
[perl5.git] / pod / perldiag.pod
index d913fa6..8cf416b 100644 (file)
@@ -561,6 +561,11 @@ checking.  Alternatively, if you are certain that you're calling the
 function correctly, you may put an ampersand before the name to avoid
 the warning.  See L<perlsub>.
 
+=item Calling POSIX::%s() is deprecated
+
+(D deprecated) You called a function whose use is deprecated.  See
+the function's name in L<POSIX> for details.
+
 =item Cannot compress integer in pack
 
 (F) An argument to pack("w",...) was too large to compress.  The BER
@@ -1299,15 +1304,16 @@ or if you use an explicit C<continue>.)
 with an assignment operator, which implies modifying the value itself.
 Perhaps you need to copy the value to a temporary, and repeat that.
 
-=item Character following "\c" must be ASCII
+=item Character following "\c" must be printable ASCII
 
-(F)(D deprecated, syntax) In C<\cI<X>>, I<X> must be an ASCII character.
-It is planned to make this fatal in all instances in Perl v5.20.  In
+(F)(D deprecated, syntax) In C<\cI<X>>, I<X> must be a printable
+(non-control) ASCII character.  This is fatal starting in v5.20 for
+non-ASCII characters, and it is planned to make this fatal in all
+instances in Perl v5.22.  In
 the cases where it isn't fatal, the character this evaluates to is
 derived by exclusive or'ing the code point of this character with 0x40.
 
-Note that non-alphabetic ASCII characters are discouraged here as well,
-and using non-printable ones will be deprecated starting in v5.18.
+Note that non-alphabetic ASCII characters are discouraged here as well.
 
 =item Character in 'C' format wrapped in pack
 
@@ -1652,7 +1658,7 @@ becomes
 
     { my $x; sub f { return $x++ } }
 
-Beginning with perl 5.9.4, you can also use C<state> variables to have
+Beginning with perl 5.10.0, you can also use C<state> variables to have
 lexicals that are initialized only once (see L<feature>):
 
     sub f { state $x; return $x++ }
@@ -1918,6 +1924,14 @@ interpolated.  If you see this error message, then you probably
 have some other C<(?...)> construct inside your character class.  See
 L<perlrecharclass/Extended Bracketed Character Classes>.
 
+=item Experimental subroutine signatures not enabled
+
+(F) To use subroutine signatures, you must first enable them:
+
+    no warnings "experimental::signatures";
+    use feature "signatures";
+    sub foo ($left, $right) { ... }
+
 =item Experimental "%s" subs not enabled
 
 (F) To use lexical subs, you must first enable them:
@@ -2222,6 +2236,9 @@ to your Perl administrator.
 
 (W illegalproto) An illegal character was found in a prototype declaration.
 Legal characters in prototypes are $, @, %, *, ;, [, ], &, \, and +.
+Perhaps you were trying to write a subroutine signature but didn't enable
+that feature first (C<use feature 'signatures'>), so your signature was
+instead interpreted as a bad prototype.
 
 =item Illegal declaration of anonymous subroutine
 
@@ -2653,7 +2670,7 @@ neither as a system call nor an ioctl call (SIOCATMARK).
 =item $* is no longer supported
 
 (D deprecated, syntax) The special variable C<$*>, deprecated in older
-perls, has been removed as of 5.9.0 and is no longer supported.  In
+perls, has been removed as of 5.10.0 and is no longer supported.  In
 previous versions of perl the use of C<$*> enabled or disabled multi-line
 matching within a string.
 
@@ -2665,7 +2682,7 @@ then all regular expressions behaved as if they were written using C</m>.)
 =item $# is no longer supported
 
 (D deprecated, syntax) The special variable C<$#>, deprecated in older
-perls, has been removed as of 5.9.3 and is no longer supported.  You
+perls, has been removed as of 5.10.0 and is no longer supported.  You
 should use the printf/sprintf functions instead.
 
 =item '%s' is not a code reference
@@ -2856,6 +2873,9 @@ appear if components are not found, or are too long.  See
 syntax of function prototypes is given a brief compile-time check for
 obvious errors like invalid characters.  A more rigorous check is run
 when the function is called.
+Perhaps the function's author was trying to write a subroutine signature
+but didn't enable that feature first (C<use feature 'signatures'>),
+so the signature was instead interpreted as a bad prototype.
 
 =item Malformed UTF-8 character (%s)
 
@@ -2905,6 +2925,15 @@ rules and perl was unable to guess how to make more progress.
 (F) Perl thought it was reading UTF-16 encoded character data but while
 doing it Perl met a malformed Unicode surrogate.
 
+=item Mandatory parameter follows optional parameter
+
+(F) In a subroutine signature, you wrote something like "$a = undef,
+$b", making an earlier parameter optional and a later one mandatory.
+Parameters are filled from left to right, so it's impossible for the
+caller to omit an earlier one and pass a later one.  If you want to act
+as if the parameters are filled from right to left, declare the rightmost
+optional and then shuffle the parameters around in the subroutine's body.
+
 =item Matched non-Unicode code point 0x%X against Unicode property; may
 not be portable
 
@@ -3195,10 +3224,12 @@ local() if you want to localize a package variable.
 (W once) Typographical errors often show up as unique variable
 names.  If you had a good reason for having a unique name, then
 just mention it again somehow to suppress the message.  The C<our>
-declaration is provided for this purpose.
+declaration is also provided for this purpose.
 
-NOTE: This warning detects symbols that have been used only once
-so $c, @c, %c, *c, &c, sub c{}, c(), and c (the filehandle or
+NOTE: This warning detects package symbols that have been used only
+once. This means lexical variables will never trigger this warning.
+It also means that all of the package variables $c, @c, %c, as well
+as *c, &c, sub c{}, c(), and c (the filehandle or
 format) are considered the same; if a program uses $c only once
 but also uses any of the others it will not trigger this warning.
 Symbols beginning with an underscore and symbols using special
@@ -3619,6 +3650,15 @@ the braces.
 (4294967295) and therefore non-portable between systems.  See
 L<perlport> for more on portability concerns.
 
+=item Odd name/value argument for subroutine
+
+(F) A subroutine using a slurpy hash parameter in its signature
+received an odd number of arguments to populate the hash.  It requires
+the arguments to be paired, with the same number of keys as values.
+The caller of the subroutine is presumably at fault.  Inconveniently,
+this error will be reported at the location of the subroutine, not that
+of the caller.
+
 =item Odd number of arguments for overload::constant
 
 (W overload) The call to overload::constant contained an odd number of
@@ -3729,6 +3769,13 @@ use an operator, but this is highly likely to be incorrect.  For
 example, if you say "*foo *foo" it will be interpreted as if you said
 "*foo * 'foo'".
 
+=item Optional parameter lacks default expression
+
+(F) In a subroutine signature, you wrote something like "$a =", making a
+named optional parameter without a default value.  A nameless optional
+parameter is permitted to have no default value, but a named one must
+have a specific default.  You probably want "$a = undef".
+
 =item "our" variable %s redeclared
 
 (W misc) You seem to have already declared the same global once before
@@ -4699,8 +4746,8 @@ always come last, to avoid ambiguity with subsequent unary operators.
 
 =item rewinddir() attempted on invalid dirhandle %s
 
-(W io) The dirhandle you tried to do a rewinddir() on is either closed or not
-really a dirhandle.  Check your control flow.
+(W io) The dirhandle you tried to do a rewinddir() on is either closed
+or not really a dirhandle.  Check your control flow.
 
 =item Scalars leaked: %d
 
@@ -4746,10 +4793,10 @@ L<perlref>.
 construct.  Remember that bracketing delimiters count nesting level.
 Missing the leading C<$> from a variable C<$m> may cause this error.
 
-Note that since Perl 5.9.0 a // can also be the I<defined-or>
+Note that since Perl 5.10.0 a // can also be the I<defined-or>
 construct, not just the empty search pattern.  Therefore code written
-in Perl 5.9.0 or later that uses the // as the I<defined-or> can be
-misparsed by pre-5.9.0 Perls as a non-terminated search pattern.
+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
 
@@ -4897,30 +4944,6 @@ less.  Please see the following for more information:
 
 You should also look at L<perlfaq9>.
 
-=item Setting $/ to a reference to %s as a form of slurp is deprecated, treating as undef
-
-(W deprecated) You assigned a reference to a scalar to C<$/> where the
-referenced item is not a positive integer. In older perls this B<appeared>
-to work the same as setting it to C<undef> but was in fact internally
-different, less efficient and with very bad luck could have resulted in
-your file being split by a stringified form of the reference.
-
-In Perl 5.19.9 this was changed so that it would be B<exactly> the same as
-setting C<$/> to undef, with the exception that this warning would be
-thrown.
-
-You are recommended to change your code to set C<$/> to C<undef>
-explicitly if you wish to slurp the file. In future versions of Perl
-assigning a reference to will throw a fatal error.
-
-=item Setting $/ to a %s reference is forbidden
-
-(F) You tried to assign a reference to a non integer to C<$/>. In older
-Perls this would have behaved similarly to setting it to a reference
-to a positive integer, where the integer was the address of the reference.
-As of Perl 5.19.9 this is a fatal error, to allow future versions of Perl
-to use non integer refs for more interesting purposes.
-
 =item setegid() not implemented
 
 (F) You tried to assign to C<$)>, and your operating system doesn't
@@ -4957,6 +4980,30 @@ didn't think so.
 forget to check the return value of your socket() call?  See
 L<perlfunc/setsockopt>.
 
+=item Setting $/ to a reference to %s as a form of slurp is deprecated, treating as undef
+
+(W deprecated) You assigned a reference to a scalar to C<$/> where the
+referenced item is not a positive integer.  In older perls this B<appeared>
+to work the same as setting it to C<undef> but was in fact internally
+different, less efficient and with very bad luck could have resulted in
+your file being split by a stringified form of the reference.
+
+In Perl 5.20.0 this was changed so that it would be B<exactly> the same as
+setting C<$/> to undef, with the exception that this warning would be
+thrown.
+
+You are recommended to change your code to set C<$/> to C<undef> explicitly
+if you wish to slurp the file. In future versions of Perl assigning
+a reference to will throw a fatal error.
+
+=item Setting $/ to %s reference is forbidden
+
+(F) You tried to assign a reference to a non integer to C<$/>.  In older
+Perls this would have behaved similarly to setting it to a reference to
+a positive integer, where the integer was the address of the reference.
+As of Perl 5.20.0 this is a fatal error, to allow future versions of Perl
+to use non-integer refs for more interesting purposes.
+
 =item shift on reference is experimental
 
 (S experimental::autoderef) C<shift> with a scalar argument is experimental
@@ -5009,6 +5056,12 @@ a compilation error, but could not be found, so it was leaked instead.
 it can reliably handle and C<sleep> probably slept for less time than
 requested.
 
+=item Slurpy parameter not last
+
+(F) In a subroutine signature, you put something after a slurpy (array or
+hash) parameter.  The slurpy parameter takes all the available arguments,
+so there can't be any left to fill later parameters.
+
 =item Smart matching a non-overloaded object breaks encapsulation
 
 (F) You should not use the C<~~> operator on an object that does not
@@ -5358,6 +5411,18 @@ warning:
 
     no warnings "experimental::regex_sets";
 
+=item The signatures feature is experimental
+
+(S experimental::signatures) This warning is emitted if you unwrap a
+subroutine's arguments using a signature.  Simply suppress the warning
+if you want to use the feature, but know that in doing so you are taking
+the risk of using an experimental feature which may change or be removed
+in a future Perl version:
+
+    no warnings "experimental::signatures";
+    use feature "signatures";
+    sub foo ($left, $right) { ... }
+
 =item The stat preceding %s wasn't an lstat
 
 (F) It makes no sense to test the current stat buffer for symbolic
@@ -5426,6 +5491,13 @@ See L<perlunicode/"User-Defined Character Properties">.
 (F) There has to be at least one argument to syscall() to specify the
 system call to call, silly dilly.
 
+=item Too few arguments for subroutine
+
+(F) A subroutine using a signature received fewer arguments than required
+by the signature.  The caller of the subroutine is presumably at fault.
+Inconveniently, this error will be reported at the location of the
+subroutine, not that of the caller.
+
 =item Too late for "-%s" option
 
 (X) The #! line (or local equivalent) in a Perl script contains the
@@ -5456,6 +5528,13 @@ BEGIN block.
 
 (F) The function requires fewer arguments than you specified.
 
+=item Too many arguments for subroutine
+
+(F) A subroutine using a signature received more arguments than required
+by the signature.  The caller of the subroutine is presumably at fault.
+Inconveniently, this error will be reported at the location of the
+subroutine, not that of the caller.
+
 =item Too many )'s
 
 (A) You've accidentally run your script through B<csh> instead of Perl.
@@ -5830,8 +5909,9 @@ subroutine.
 %d
 
 (F) The Perl parser has no idea what to do with the specified character
-in your Perl script (or eval) near the specified column.  Perhaps you tried 
-to run a compressed script, a binary program, or a directory as a Perl program.
+in your Perl script (or eval) near the specified column.  Perhaps you
+tried  to run a compressed script, a binary program, or a directory as
+a Perl program.
 
 =item Unrecognized escape \%c in character class in regex; marked by
 S<<-- HERE> in m/%s/
@@ -6002,6 +6082,11 @@ See L<Win32> for more information.
 You probably meant to use C<$]> instead.  C<$[> is the base for indexing
 arrays.  C<$]> is the Perl version number in decimal.
 
+=item Use "%s" instead of "%s"
+
+(F) The second listed construct is no longer legal.  Use the first one
+instead.
+
 =item Useless assignment to a temporary
 
 (W misc) You assigned to an lvalue subroutine, but what
@@ -6162,13 +6247,6 @@ you can write it as C<push(@tied_array,())> to avoid this warning.
 (F) The "use" keyword is recognized and executed at compile time, and
 returns no useful value.  See L<perlmod>.
 
-=item Use "%c" instead of "\c{"
-
-(F) The C<\cI<X>> construct is intended to be a way to specify
-non-printable characters.  You used it with a C<"{"> which evaluates to
-C<";">, which is printable.  On ASCII platforms, just use a semi-colon
-or a backslash-semi-colon without the C<"\c">.
-
 =item Use of assignment to $[ is deprecated
 
 (D deprecated) The C<$[> variable (index of the first element in an array)
@@ -6177,7 +6255,8 @@ is deprecated.  See L<perlvar/"$[">.
 =item Use of bare << to mean <<"" is deprecated
 
 (D deprecated) You are now encouraged to use the explicitly quoted
-form if you wish to use an empty line as the terminator of the here-document.
+form if you wish to use an empty line as the terminator of the
+here-document.
 
 =item Use of chdir('') or chdir(undef) as chdir() deprecated
 
@@ -6472,8 +6551,8 @@ gone out of scope, for example,
     }
     f()->();
 
-Here, when the '$a' in the eval is being compiled, f() is not currently being
-executed, so its $a is not available for capture.
+Here, when the '$a' in the eval is being compiled, f() is not currently
+being executed, so its $a is not available for capture.
 
 =item Variable "%s" is not imported%s
 
@@ -6661,6 +6740,6 @@ shows whereabouts in the regular expression the problem was discovered.
 
 =head1 SEE ALSO
 
-L<warnings>, L<perllexwarn>, L<diagnostics>.
+L<warnings>, L<diagnostics>.
 
 =cut